gunicorn 的 Systemd 启动服务处于非活动状态

gunicorn 的 Systemd 启动服务处于非活动状态

我已经配置了 gunicorn.py 配置文件来启动绑定到 nginx 的 python 服务器。除了启动服务外,一切正常。我正在使用 systemd 服务配置,以下是 gunicorn 服务:

[Unit]
Description = gunicorn daemon
#Requires = gunicorn.socket
After = network.target

[Service]
#PIDFile = /run/gunicorn.pid
WorkingDirectory = /var/www/LTT/ltt
Group = devs
User = root
Type = forking
ExecStart = /usr/local/bin/gunicorn -c gunicorn.py app_ltt:app
ExecReload = /bin/kill -s HUP $MAINPID
ExecStop = /bin/kill -s TERM $MAINPID

[Install]
WantedBy = multi-user.target

这是尝试启动时的非活动消息(但服务已启用)systemctl 启动时 GUNICORN 服务状态

有人建议将 daemon=True 添加到 gunciorn 配置中以使它正常工作,但这没有帮助。

#Bidnign
bind = 'unix:/var/www/LTT/ltt/gunicorn.sock'
backlog = 2048
#Workers
#num = 1+2-4 x $NUM_CORES
workers = 1
worker_class = 'gevent'
worker_connections = 1000
#Fct
spew = False
#Server
umask = 007
daemon = True
user = 'www-data'
group = 'www-data'
pidfile = '/run/gunicorn.pid'

日志更新 我在 gunicorn 配置文件中添加了带有调试模式的 errorlog.log,当我自己运行该命令时,它可以正常工作并写入文件,但是当我运行systemctl 启动 gunicorn它甚至没有创建文件,所以我无法读取日志。

accesslog = '/var/log/gunicorn/accesslog.log'
errorlog = '/var/log/gunicorn/errorlog.log'
loglevel = 'debug'

日志更新-2 我已将 gunicorn chown 到 www-data 并在 gunicorn 服务中使用它,它启动了 gunicorn(将其写入日志)但没有进一步的操作(监听套接字,启动 gevent worker)。这里是日志输出: GUNICORN 错误日志

相关内容