參考:http://blog.csdn.net/wawa8899/article/details/52743861html
參考:http://www.cnblogs.com/mountaingeek/p/5911291.htmlpython
參考:http://www.linuxyw.com/718.htmllinux
參考:http://www.iitshare.com/supervisord-manage-process.htmlshell
參考:http://stackoverflow.com/questions/20346851/running-celery-as-rootapi
運行生成配置文件:bash
[root@host /]# echo_supervisord_conf > /etc/supervisord.conf ... pkg_resources.DistributionNotFound: meld3>=0.6.5 找到supervisor-3.3.1-py2.7.egg-info/requires.txt,把文件裏面meld3 >= 0.6.5註釋掉,而後再執行
配置ui
[program:dopcelerybeat] command=python manage.py celery beat numprocs=1 directory=/path/ autostart=true startsecs=10 startretries=3 stopwaitsecs=600 killasgroup=true user=root redirect_stderr=true stdout_logfile=/path/logs/supervisord-celery-beat.log stderr_logfile=/path/logs/supervisord-celery-beat-error.log [program:dopceleryworker] command=python manage.py celery worker -l info numprocs=1 directory=/path/ autostart=true startsecs=10 startretries=3 stopwaitsecs=600 killasgroup=true user=root redirect_stderr=true stdout_logfile=/path/logs/supervisord-celery-worker.log stderr_logfile=/path/logs/supervisord-celery-worker-error.log [group:dopcelery] programs=dopcelerybeat,dopceleryworker ; priority=999 ; the relative start priority (default 999)
運行celery時報錯的解決方法:spa
1st solution - Manually type command at terminal $ export C_FORCE_ROOT='true' 2nd solution - Edit shell configuration $ vi ~/.bashrc # add following line export C_FORCE_ROOT='true' $ source ~/.bashrc 3rd solution - Edit manage.py of Django import os if __name__ == '__main__': os.environ.setdefault('C_FORCE_ROOT', 'true') os.environ.setdefault('DJANGO_SETTINGS_MODULE', '{PATH TO SETTINGS FILE}') execute_from_command_line(sys.argv)
命令supervisorctl可使用start/stop/status管理每一個進程.net
[root@d11092353 supervisor-3.3.1-py2.7.egg-info]# supervisorctl dopcelery:dopcelerybeat STOPPED Dec 15 04:40 PM dopcelery:dopceleryworker RUNNING pid 31136, uptime 0:27:58 supervisor> status dopcelery:dopcelerybeat dopcelery:dopcelerybeat STOPPED Dec 15 04:40 PM supervisor>
supervisorctl API:官方文檔 http://www.supervisord.org/api.htmlpwa
import xmlrpclib server = xmlrpclib.Server('http://127.0.0.1:9900/RPC2') server.supervisor.getState() 返回 >>> {'statename': 'RUNNING', 'statecode': 1} server.supervisor.getProcessInfo('group:name') 返回 >>> 任務狀態