首页 > 解决方案 > 解决烧瓶和八度音程的多个问题

问题描述

我正在尝试运行一个烧瓶应用程序,它使用 octave 和 python oct2py 包与 Octave 进行通信。我设置了一个 python venv 并正在运行该应用程序。

简单的烧瓶应用程序似乎工作正常,因为它接受 Post 请求并做出响应。当我尝试添加八度功能时,该应用程序运行良好。使用直接 gunicorn 绑定,该应用程序也可以正常工作。

当我尝试创建systemd service单元文件并且代码运行八度时,问题就开始了。

我创建了一个类似的服务/etc/systemd/system/my_project.service,它的内容如下。

[Unit]
Description=Gunicorn instance to serve flask app
After=network.target

[Service]
User=some_user
Group=www-data
WorkingDirectory=/home/some_user/project_dir
Environment="PATH=/home/some_user/project_dir/venv/bin"
ExecStart=/home/some_user/project_dir/venv/bin/gunicorn --workers 3 --bind unix:project_dir.sock -m 007 wsgi:app

[Install]
WantedBy=multi-user.target

查看状态后,它会引发错误,例如

错误日志

重新启动服务后它抛出

gunicorn[1690]:     self.restart()
gunicorn[1690]:   File "/home/some_user/project_dir/venv/lib/python3.8/site-packages/oc>
gunicorn[1690]:     self._engine = OctaveEngine(stdin_handler=self._handle_stdin,
gunicorn[1690]:   File "/home/some_user/project_dir/venv/lib/python3.8/site-packages/oc>
gunicorn[1690]:     self.executable = self._get_executable()
gunicorn[1690]:   File "/home/some_user/project_dir/venv/lib/python3.8/site-packages/oc>
gunicorn[1690]:     raise OSError('octave-cli not found, please see README')
gunicorn[1690]: OSError: octave-cli not found, please see README
systemd[1]: my_project.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: my_project.service: Failed with result 'exit-code'.

我在很多地方搜索了错误,但无法像这里 一样解决它

对于 octave,我尝试在有和没有 venv 活动的情况下从终端运行 octave 和 octave-cli,它会打开 octave,所以我无法找出确切的原因。

如果我直接在终端上运行命令,它将运行应用程序而不会出现任何错误

gunicorn --bind 127.1.0.1:5000 wsgi:app

wsgi.py 文件看起来像这样

from my_project import app

if __name__ == "__main__":
    app.run()

任何建议如何解决这个问题?

标签: pythonflaskgunicorn

解决方案


推荐阅读