【问题标题】:Supervisor: ERROR (spawn error) when trying to launch gunicorn主管:尝试启动 gunicorn 时出现错误(生成错误)
【发布时间】:2018-05-14 19:56:18
【问题描述】:

我一直在尝试使用主管 per these instructions 设置 gunicorn。但是当我运行时

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start Server-CardLearning

我收到错误Server-CardLearning: ERROR (spawn error)

我的配置文件很简单。

[program:Server-CardLearning]
command = gunicorn app:app -b localhost:8000
directory = /home/alexg/www/<flask project>
user = www-data

我的日志文件中出现以下错误。

...
...
2017-11-30 13:48:52,276 INFO gave up: Server-CardLearning entered FATAL state, too many start retries too quickly
2017-11-30 13:49:10,595 INFO spawnerr: unknown error making dispatchers for 'Server-CardLearning': ENOENT
2017-11-30 13:49:11,597 INFO spawnerr: unknown error making dispatchers for 'Server-CardLearning': ENOENT
2017-11-30 13:49:13,599 INFO spawnerr: unknown error making dispatchers for 'Server-CardLearning': ENOENT
2017-11-30 13:49:16,603 INFO spawnerr: unknown error making dispatchers for 'Server-CardLearning': ENOENT
2017-11-30 13:49:16,603 INFO gave up: Server-CardLearning entered FATAL state, too many start retries too quickly
2017-11-30 13:58:12,101 INFO spawned: 'Server-CardLearning' with pid 13725
2017-11-30 13:58:12,560 INFO exited: Server-CardLearning (exit status 3; not expected)
2017-11-30 13:58:13,563 INFO spawned: 'Server-CardLearning' with pid 13730
2017-11-30 13:58:13,982 INFO exited: Server-CardLearning (exit status 3; not expected)
2017-11-30 13:58:15,986 INFO spawned: 'Server-CardLearning' with pid 13735
2017-11-30 13:58:16,411 INFO exited: Server-CardLearning (exit status 3; not expected)
2017-11-30 13:58:19,416 INFO spawned: 'Server-CardLearning' with pid 13742
2017-11-30 13:58:19,842 INFO exited: Server-CardLearning (exit status 3; not expected)
2017-11-30 13:58:20,843 INFO gave up: Server-CardLearning entered FATAL state, too many start retries too quickly
...
...
2017-11-30 14:10:29,728 INFO spawned: 'Server-CardLearning' with pid 13901
2017-11-30 14:10:29,957 INFO exited: Server-CardLearning (exit status 2; not expected)
2017-11-30 14:10:30,961 INFO spawned: 'Server-CardLearning' with pid 13902
2017-11-30 14:10:31,193 INFO exited: Server-CardLearning (exit status 2; not expected)
2017-11-30 14:10:33,200 INFO spawned: 'Server-CardLearning' with pid 13903
2017-11-30 14:10:33,436 INFO exited: Server-CardLearning (exit status 2; not expected)
2017-11-30 14:10:36,443 INFO spawned: 'Server-CardLearning' with pid 13904
2017-11-30 14:10:36,681 INFO exited: Server-CardLearning (exit status 2; not expected)
2017-11-30 14:10:37,682 INFO gave up: Server-CardLearning entered FATAL state, too many start retries too quickly

我哪里错了?我已经尝试了一些我在堆栈溢出时看到的东西,但没有任何东西证明与这个问题有关。

【问题讨论】:

    标签: python flask gunicorn supervisord


    【解决方案1】:

    问题的根源似乎是我遇到了app.py 的问题。我使用了一些已安装在本地计算机上但未安装在服务器上的 Flask 库,由于某种原因,当我通过 flask run --host=0.0.0.0 运行服务器时,我没有遇到大错误。

    我通过调整位于/etc/supervisor/conf.d/Server-CardLearning.conf 的主管.conf 文件解决了这个问题

    新的.conf 文件内容如下:

    [program:Server-CardLearning]
    environment=SECRET_KEY="some_secret_key"
    command=gunicorn app:app -b localhost:8000
    directory=/home/alexg/www/Server-CardLearning
    user=alexg
    autostart=true
    stderr_logfile=/var/log/supervisor/test.err.log
    stdout_logfile=/var/log/supervisor/test.out.log
    

    通过添加我能够运行的两个日志文件:

    cat /var/log/supervisor/test.err.log

    看看我有一个卸载的库! ~喘气!~

    安装完库后,我跑了:

    sudo supervisorctl reread
    sudo supervisorctl update
    sudo supervisorctl start Server-CardLearning
    

    现在,如果这不能解决问题,我还发现在主管控制台中进行挖掘很有帮助:

    $ sudo supervisorctl
    supervisor> help
    supervisor> status
    

    我希望这可以帮助别人!

    【讨论】:

    • 看起来supervisor 现在默认登录了:` $ sudo ls /var/log/supervisor/ -rw------- 1 root root 64K Nov 15 16:40 ocp10-gunicorn-stderr---supervisor-xxx.log -rw------- 1 root root 550 Nov 15 16:40 ocp10-gunicorn-stdout---supervisor-xxx.log -rw-r-- r-- 1 root root 6.8K Nov 15 16:40 supervisord.log`
    【解决方案2】:

    在我的情况下,我不小心删除了主管日志指向的日志文件夹,因此创建这些文件夹并重新启动主管就可以了。

    supervisor.conf 示例

    [program:Server-CardLearning]
    environment=SECRET_KEY="some_secret_key"
    command=gunicorn app:app -b localhost:8000
    directory=/home/alexg/www/Server-CardLearning
    user=alexg
    autostart=true
    stderr_logfile=/var/log/supervisor/test.err.log
    stdout_logfile=/var/log/supervisor/test.out.log
    

    所以我所做的就是:-

    mkdir /var/log/supervisor/
    

    之后:-

    sudo supervisorctl status all
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-08
      • 2013-07-23
      相关资源
      最近更新 更多