0

我用Supervisor做进程控制

/etc/supervisor/conf.d/onehomeServer.conf

[program:onehomeServer]
command=sudo /home/fanfei/onehomeServer/env/bin/gunicorn --bind unix:/tmp/www.fanfei.site.socket onehomeServer.asgi:application
directory=/home/fanfei/onehomeServer/               ; 执行前要不要先cd到目录$
autostart=true                ; 随着supervisord的启动而启动
autorestart=true              ; 自动重启。。当然要选上了
startretries=10               ; 启动失败时的最多重试次数
exitcodes=0                   ; 正常退出代码
stopsignal=KILL               ; 用来杀死进程的信号
stopwaitsecs=10               ; 发送SIGKILL前的等待时间
redirect_stderr=true          ; 重定向stderr到stdout
stdout_logfile=/home/fanfei/onehomeServer/logfile.log        ; 指定日志文件
; 默认为 false,如果设置为 true,当进程收到 stop 信号时,会自动将该信号发给该进$
stopasgroup=true             ; send stop signal to the UNIX process
; 默认为 false,如果设置为 true,当进程收到 kill 信号时,会自动将该信号发给该进$
killasgroup=true             ; SIGKILL the UNIX process group (def false)

但是,当我执行

sudo supervisorctl reload

sudo supervisorctl restart all

以后,网站是打不开的。日志文件如下:

[2019-02-27 10:32:40 +0800] [1323] [INFO] Starting gunicorn 19.9.0
[2019-02-27 10:32:40 +0800] [1323] [INFO] Listening at: unix:/tmp/www.fanfei.site.socket (1323)
[2019-02-27 10:32:40 +0800] [1323] [INFO] Using worker: sync
[2019-02-27 10:32:40 +0800] [1326] [INFO] Booting worker with pid: 1326
[2019-02-27 10:32:59 +0800] [1337] [INFO] Starting gunicorn 19.9.0
[2019-02-27 10:32:59 +0800] [1337] [INFO] Listening at: unix:/tmp/www.fanfei.site.socket (1337)
[2019-02-27 10:32:59 +0800] [1337] [INFO] Using worker: sync
[2019-02-27 10:32:59 +0800] [1340] [INFO] Booting worker with pid: 1340

如果我在命令行直接执行

sudo /home/fanfei/onehomeServer/env/bin/gunicorn --bind unix:/tmp/www.fanfei.site.socket onehomeServer.wsgi:application

网站可以打开:

[2019-02-27 09:41:56 +0800] [1143] [INFO] Starting gunicorn 19.9.0
[2019-02-27 09:41:56 +0800] [1143] [INFO] Listening at: unix:/tmp/www.fanfei.site.socket (1143)
[2019-02-27 09:41:56 +0800] [1143] [INFO] Using worker: sync
[2019-02-27 09:41:56 +0800] [1146] [INFO] Booting worker with pid: 1146
^C[2019-02-27 09:42:42 +0800] [1143] [INFO] Handling signal: int
[2019-02-27 09:42:42 +0800] [1146] [INFO] Worker exiting (pid: 1146)
[2019-02-27 09:42:43 +0800] [1143] [INFO] Shutting down: Master

请问是哪里的问题

凡沸 228
2月27日提问
1 个回答
0

已采纳

注意前后命令不一致

sudo /home/fanfei/onehomeServer/env/bin/gunicorn --bind unix:/tmp/www.fanfei.site.socket onehomeServer.asgi:application
sudo /home/fanfei/onehomeServer/env/bin/gunicorn --bind unix:/tmp/www.fanfei.site.socket onehomeServer.wsgi:application

撰写答案

推广链接