【问题标题】:supervisor gunicorn flask error主管 gunicorn 烧瓶错误
【发布时间】:2016-10-31 10:07:05
【问题描述】:

我已经用 gunicorn 部署了我的烧瓶应用程序,当我使用 gunicorn 启动我的烧瓶应用程序时,它工作正常。当我更改为使用主管观看 gunicorn 时,我可以访问我的网站,但主管给出了这些日志:

2016-10-31 17:49:49,967 INFO supervisord started with pid 32949
2016-10-31 17:49:50,970 INFO spawned: 'vservice' with pid 32952
2016-10-31 17:49:51,971 INFO success: vservice entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2016-10-31 17:49:56,285 INFO exited: vservice (exit status 1; not expected)
2016-10-31 17:49:57,287 INFO spawned: 'vservice' with pid 32955
2016-10-31 17:49:58,289 INFO success: vservice entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2016-10-31 17:50:02,605 INFO exited: vservice (exit status 1; not expected)
2016-10-31 17:50:03,608 INFO spawned: 'vservice' with pid 32960
2016-10-31 17:50:04,609 INFO success: vservice entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2016-10-31 17:50:08,924 INFO exited: vservice (exit status 1; not expected)
2016-10-31 17:50:09,926 INFO spawned: 'vservice' with pid 32965
2016-10-31 17:50:10,927 INFO success: vservice entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

和主管 stderrlog 是这样的:

Error: Already running on PID 30874 (or pid file 'log/gunicorn.pid' is stale)

这是我的 gunicorn 配置文件:

import gevent.monkey
import multiprocessing

gevent.monkey.patch_all()

bind = '0.0.0.0:9000'

loglevel = 'error'
logfile = 'log/debug.log'
accesslog = 'log/access.log'
access_log_format = '%(h)s %(t)s %(U)s %(q)s'
errorlog = 'log/error.log'

pidfile = 'log/gunicorn.pid'

# number of processes
workers = multiprocessing.cpu_count() * 2 + 1
# number of threads of per process
threads = multiprocessing.cpu_count() * 2
worker_class = 'gevent'

这是我的主管配置文件:

[program:vservice]
command=/data/server/venv/bin/gunicorn -c /data/server/gun.py manager:app
directory=/data/server/
stdout_logfile=/data/supervisor/log/stdout.log
stderr_logfile=/data/supervisor/log/stderr.log

当我使用 gunicorn -c gun.py manager:app 时,我的应用程序工作正常,但是当我使用主管运行它时,它会出现上述错误,我仍然可以访问我的网络,看起来我的应用程序有效,但是主管给出的错误是什么意思?它对我的部署有什么不好的影响吗?

谢谢。

【问题讨论】:

    标签: flask gunicorn supervisord


    【解决方案1】:

    我从这里得到了一个想法。 https://github.com/benoitc/gunicorn/issues/520#issuecomment-236301509

    尝试使用 bash 脚本运行 gunicorn。您的主管配置文件应如下所示:

    [program:vservice]
    command=/path-to-bash-script/gunicorn.sh
    directory=/data/server/
    stdout_logfile=/data/supervisor/log/stdout.log
    stderr_logfile=/data/supervisor/log/stderr.log
    

    设置您的 gunicorn.sh 为您的 gunicorn 应用运行 exec 命令

    #!/bin/sh
    exec /data/server/venv/bin/gunicorn -c /data/server/gun.py manager:app
    

    并从您的 gunicorn 配置文件中删除 pidfile = 'log/gunicorn.pid' 行。

    这是因为你的 bash 脚本是受监督的,而不是 gunicorn。

    【讨论】:

      猜你喜欢
      • 2017-05-11
      • 2017-11-12
      • 1970-01-01
      • 2016-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      相关资源
      最近更新 更多