gpt4 book ai didi

flask - 主管 gunicorn flask 错误

转载 作者:行者123 更新时间:2023-12-03 17:00:33 37 4
gpt4 key购买 nike

我已经用 gunicorn 部署了我的 flask 应用程序,当我使用 gunicorn 启动我的 flask 应用程序时,它工作正常。当我更改为使用主管观看 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 时,我的应用程序运行良好,但是当我使用主管运行它时,它会出现上述错误,我仍然可以访问我的网站,而且我的应用程序似乎可以运行,但是主管给出的错误是什么意思?它对我的部署有什么不好的影响吗?

谢谢。

最佳答案

我从这里得到了一个想法。
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

并带走线路 pidfile = 'log/gunicorn.pid'从您的 gunicorn 配置文件中。

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

关于flask - 主管 gunicorn flask 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40340053/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com