标签:参考 nic socket linux .so pidfile 后台 ann 开头
supervisor是Linux下一个便利的启动和监控服务的命令。
; supervisor config file [unix_http_server] ; supervisor与supervisorctl的通讯 file=/var/run/supervisor.sock ; (the path to the socket file) should match serverurl in section supervisorctl chmod=0700 ; sockef file mode (default 0700) [supervisord] ; 必须有,用来配置supervisord logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) childlogdir=/var/log/supervisor ; (‘AUTO‘ child log dir, default $TEMP) ; the below section must remain in the config file for RPC ; (supervisorctl/web interface) to work, additional interfaces may be ; added by defining them in separate rpcinterface: sections [rpcinterface:supervisor] ; 这个配置项必须有 supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] ; 必须有,用于配置supervisorctl serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket ; The [include] section can just contain the "files" setting. This ; setting can list multiple files (separated by whitespace or ; newlines). It can also contain wildcards. The filenames are ; interpreted as relative to this file. Included files *cannot* ; include files themselves. [include] ;引入其它配置文件 files = /path/to/*.conf # other configuration files you want to include [program:api4c] ;应用程序的配置 command=/path/to/python/env/bin/gunicorn -w 1 -b 0.0.0.0:8888 wsgi:application ; 执行你的命令,不能是用于启动守护进程,因为supervisor就是用来作为守护进程的 directory=/home/ubuntu/4c-entry/api4c ; chdir to here before command run startsecs=0 ; stopwaitsecs=0 ; autostart=true ; supervisord启动的时候自动运行 autorestart=true ; 当程序中断的时候是否重启 stop,true,false,unexpected stdout_logfile=/path/to/logfile.log ; 必须已经存在
stderr_logfile=/path/to/std/err/log/for4c.err
命令使用实例:
来源: http://chenxiaoyu.org/2011/05/31/python-supervisor.html
配置项:
[program:hello] command=python /home/smallfish/hello.py autorstart=true stdout_logfile=/home/smallfish/hello.log 命令
shell> sudo /etc/init.d/supervisor start -- 启动supervisor服务 shell> sudo supervisorctl status hello -- 获取hello服务的状态,因为是autorstart,这里已经启动了 hello RUNNING pid 1159, uptime 0:20:32 shell> sudo supervisorctl stop hello -- 停止hello服务 hello: stopped shell> sudo supervisorctl stop hello -- 再次停止hello,会有错误信息 hello: ERROR (not running) shell> sudo supervisorctl start hello -- 启动hello服务 hello: started
标签:参考 nic socket linux .so pidfile 后台 ann 开头
原文地址:http://www.cnblogs.com/zhangjpn/p/7056324.html