码迷,mamicode.com
首页 > 编程语言 > 详细

【Python】supervisor安装和管理celery

时间:2016-12-15 17:25:52      阅读:330      评论:0      收藏:0      [点我收藏+]

标签:data   get   rect   time   lan   question   import   out   ams   

参考:http://blog.csdn.net/wawa8899/article/details/52743861

参考:http://www.cnblogs.com/mountaingeek/p/5911291.html

参考:http://www.linuxyw.com/718.html

参考:http://www.iitshare.com/supervisord-manage-process.html

参考:http://stackoverflow.com/questions/20346851/running-celery-as-root

运行生成配置文件:

[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注释掉,然后再执行

 

配置

[program:dopcelerybeat]
command=python manage.py celery beat
numprocs=1
directory=/data1/vhosts/dop.leju.com/
autostart=true
startsecs=10
startretries=3
stopwaitsecs=600
killasgroup=true
user=root
redirect_stderr=true
stdout_logfile=/data1/logs/supervisord-celery-beat.log
stderr_logfile=/data1/logs/supervisord-celery-beat-error.log

[program:dopceleryworker]
command=python manage.py celery worker -l info
numprocs=1
directory=/data1/vhosts/dop.leju.com/
autostart=true
startsecs=10
startretries=3
stopwaitsecs=600
killasgroup=true
user=root
redirect_stderr=true
stdout_logfile=/data1/logs/supervisord-celery-worker.log
stderr_logfile=/data1/logs/supervisord-celery-worker-error.log

[group:dopcelery]
programs=dopcelerybeat,dopceleryworker
; priority=999                  ; the relative start priority (default 999)

 

运行celery时报错的解决方法:

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管理每个进程

[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> 

 

【Python】supervisor安装和管理celery

标签:data   get   rect   time   lan   question   import   out   ams   

原文地址:http://www.cnblogs.com/jiangxu67/p/6183911.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!