我的 supervisor.conf 如下:
; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Notes:
; - Shell expansion ("~" or "$HOME") is not supported. Environment
; variables can be expanded using this syntax: "%(ENV_HOME)s".
; - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
[inet_http_server] ; inet (TCP) server disabled by default
port=127.0.0.1:9001 ; (ip_address:port specifier, *:port for all iface)
username=user ; (default is no username (open server))
password=123 ; (default is no password (open server))
[supervisord]
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
username=user ; should be same as http_username if set
password=123 ; should be same as http_password if set
[include]
files =ci_ios/webhook/wsgi.py
[program:wsgi]
command=~/Documents/supervisor/env/bin/gunicorn --chdir ~/Documents/supervisor
/ci_ios/webhook -b 0.0.0.0:8000 wsgi:application
startsecs=0
stopwaitsecs=0
autostart=false
autorestart=true
stdout_logfile=/tmp/gunicorn.log
stderr_logfile=/tmp/gunicorn.err
然后我直接启动命令,~/Documents/supervisor/env/bin/gunicorn --chdir ~/Documents/supervisor/ci_ios/webhook -b 0.0.0.0:8000 wsgi:application
,
没有报错,可以正常启动:
Starting gunicorn 19.6.0
[2016-12-29 15:23:45 +0800] [35578] [INFO] Listening at: http://0.0.0.0:8000 (35578)
[2016-12-29 15:23:45 +0800] [35578] [INFO] Using worker: sync
[2016-12-29 15:23:45 +0800] [35581] [INFO] Booting worker with pid: 35581
^C[2016-12-29 15:23:54 +0800] [35578] [INFO] Handling signal: int
[2016-12-29 15:23:54 +0800] [35581] [INFO] Worker exiting (pid: 35581)
但是我通过supervisord -c supervisor.conf
就会报错:
Error: File contains no section headers.
file: /Users/djx/Documents/supervisor/ci_ios/webhook/wsgi.py, line: 2
'from __future__ import with_statement\n'
For help, use /Users/djx/Documents/supervisor/env/bin/supervisord -h
可是谷歌了半天也不知到底该怎么改,我保存的 py 格式是 UTF-8 无 BOM 。
还有我的项目目录的结构是
~/Documents/supervisor/
ci_ios/webhook/wsgi.py
supervisor.conf
希望大神赶快出现,我实在无力解决。
1
xiuc001 2016-12-29 21:49:13 +08:00 via iPhone
files 这个节点是用来加载配置的,你这个 python 文件是什么内容?一个配置文件写一个应用( program:app )
|
2
xiuc001 2016-12-29 21:50:07 +08:00 via iPhone
还有路径最好别用~,用绝对路径
|
3
louzhumuyou OP @xiuc001 我这里的 python 文件内容是
``` #coding=utf-8 from __future__ import with_statement from app import create_app application = create_app() if __name__ == "__main__": application.run() ``` |
4
xiuc001 2016-12-29 22:33:36 +08:00
你把下面这段放到一个文件里面
[program:wsgi] command=~/Documents/supervisor/env/bin/gunicorn --chdir ~/Documents/supervisor /ci_ios/webhook -b 0.0.0.0:8000 wsgi:application startsecs=0 stopwaitsecs=0 autostart=false autorestart=true stdout_logfile=/tmp/gunicorn.log stderr_logfile=/tmp/gunicorn.err 然后 file 这个 section 包含这个文件所在的目录 再重启 supervisord 就好了 你在命令行执行 echo_supervisord_conf ,看看 files 的例子就知道了 |
5
louzhumuyou OP @xiuc001 谢谢 我发现我自己搞定了 谢谢
|