我正在尝试使用 Apache 和 mod_wsgi 在 CentOS 7 服务器上部署 Django 应用程序。该应用程序使用plotly库来创建图形,并且plotly使用orca应用程序将创建的图形导出为图像。我使用集成的 django Web 服务器测试了该应用程序 - 一切都运行良好。所以我根据官方文档设置了Apache和mod_wsgi。当我连接到 Apache 时,应用程序可以运行,但无法导出图表。浏览器最终出现网关超时错误。我将记录器消息插入到创建和导出图表的代码中。代码运行直到这一行:
static_image_bytes = plotly.io.to_image(figure, format='png', width=800, height=450)
Run Code Online (Sandbox Code Playgroud)
此行应运行本地 Orca 应用程序并将figure对象转换为 PNG 图像字节。Orca 需要 X11 显示服务器,CentOS 安装时没有 GUI。我正在使用 Xvfb 来模拟 X11(根据 Orca 的 github 页面)。Orca 应用程序是从 github 下载的 AppImage。
/bin/逆戟鲸
#!/bin/bash
echo "`date` - ORCA STARTING with $@" >> /tmp/orca.log
xvfb-run /usr/u/s/orca-1.2.1-x86_64.AppImage "$@"
echo "`date` - ORCA FINISHED" >> /tmp/orca.log
Run Code Online (Sandbox Code Playgroud)
另外,我尝试/bin/orca使用以下方法直接链接到 AppImage:
ln -s /usr/u/s/orca-1.2.1-x86_64.AppImage /bin/orca
Run Code Online (Sandbox Code Playgroud)
并将这一行添加到我的代码中: …