Systemd和Gunicorn需要某种wsgi文件作为最后一个arg ExecStart
:http : //docs.gunicorn.org/en/latest/deploy.html?highlight=ExecStart#systemd
在Django中,这在主模块中为wsgi.py
:
ExecStart=/home/admin/django/bin/gunicorn --config /home/admin/src/gunicorn.py --bind unix:/tmp/api.sock myapp.wsgi
但是,在使用Sanic和uvloop时,该文件显然不存在(我相信新协议称为ASGI)。我尝试将其替换为app.py
毫无用地的方法:
ExecStart=/home/admin/sanic/bin/gunicorn --config /home/admin/src/gunicorn.py --bind unix:/tmp/api.sock myapp.app
使用Sanic时应如何配置此参数?
如果您想以systemd开始sanic,为什么不使用supervisrod:Supervisord。
引导->系统->主管-> Gunicorn-> sanic
[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file
[supervisord]
logfile=/var/log/supervisord/supervisord.log ; supervisord log file
logfile_maxbytes=50MB ; maximum size of logfile before rotation
logfile_backups=10 ; number of backed up logfiles
loglevel=error ; info, debug, warn, trace
pidfile=/var/run/supervisord.pid ; pidfile location
nodaemon=false ; run supervisord as a daemon
minfds=1024 ; number of startup file descriptors
minprocs=200 ; number of process descriptors
user=root ; default user
childlogdir=/var/log/supervisord/ ; where child log files will live
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
[program:ctrlapi]
directory=/home/ubuntu/api
command=/home/ubuntu/api/venv3/bin/gunicorn api:app --bind 0.0.0.0:8000 --worker-class sanic.worker.GunicornWorker -w 2
stderr_logfile = log/api_stderr.log
stdout_logfile = log/api_stdout.log
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句