【问题标题】:Python: supervisor configure file to execute gunicornPython:主管配置文件以执行gunicorn
【发布时间】:2016-03-24 09:18:47
【问题描述】:

python新手,我用Flask+gunicorn+supervisor+ngnix来运行一个服务器。而且每个都设置得很好,我的问题是我不能使用主管让 gunicorn 运行一些执行。
下面是文件的层次结构:

.  
├── logs  
│   ├── access.log  
│   └── gunicorn_supervisor.log  
└── tserver  
    ├── bin  
    ├── build  
    ├── flasky   
    │   ├── @   
    │   ├── app  
    │   ├── hello.py  
    │   ├── LICENSE   
    │   └── README.md    
    ├── gunicorn.conf  
    ├── include  
    ├── lib  
    ├── local  
    └── pip-selfcheck.json   

tserver 由 virtualenv 创建。

/etc/supervisor/conf.d/tserver.conf:

[program:tserver]
command=/home/jason/tserver/bin/gunicorn hello:app -c /home/jason/tserver/gunicorn.conf
directory=/home/jason/tserver/
user=jason
autostart=true
autorestart=true
stdout_logfile=/home/jason/logs/gunicorn_supervisor.log

我的目的是让主管让gunicorn运行hello.py,但它不起作用。我用sudo supervisor status查看状态发现:

tserver      FATAL      Exited too quickly (process log may have details) 

我有一种强烈的感觉,问题一定来自tserver.conf,尤其是command

查看文件,hello.py在名为“flasky”的文件中,所以command=/home/jason/tserver/bin/gunicorn hello:app -c /home/jason/tserver/gunicorn.conf我认为路径有问题。但是command=/home/jason/tserver/bin/gunicorn ./hello:app -c /home/jason/tserver/gunicorn.conf 仍然不起作用。

而且我认为对于有经验的人来说这是一个非常愚蠢的问题,但是作为一个新手我被卡住了,所以请给我一个详细的解决方案,因为我已经阅读了相关文件并没有得到它。感谢您的青睐。

【问题讨论】:

  • 您是否尝试过从命令行运行 gunicorn 命令以确保其正确无误?
  • @Connie 请告诉我运行 gunicorn 的命令,举个例子就可以了,非常感谢。

标签: python flask gunicorn supervisord


【解决方案1】:

最后我发现我的错误,我将自己的环境 scp 到服务器,这使得 gunicorn 无法工作。我不知道原因,但是当我重新安装 env 和 gunicorn 时,它可以工作。

更重要的是,hello.pyflasky 中,所以tserver.conf 中的directory 应该是:

directory=/home/jason/tserver/flasky/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-09
    • 1970-01-01
    • 2018-03-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多