如何在ubuntu服务器上守护django芹菜定期任务? [英] How to daemonize django celery periodic task on ubuntu server?
问题描述
运行任务:
python manage.py celery beat
运行worker:
python manage.py celery worker --loglevel = info
我使用otp,rabbitmq服务器和Django的芹菜。
它工作正常。
我在ubuntu服务器上上传了该项目。我想守护这些。
为此,我创建了一个文件/ etc / default / celeryd,如下配置设置。
#节点名称开始,这里我们有一个节点
CELERYD_NODES =w1
#或者我们可以有三个节点:$ b $ b#CELERYD_NODES =w1 w2 w3
#在哪里chdir开始。
CELERYD_CHDIR =/ home / sandbox / myprojrepo / myproj
#如何调用manage.py celeryd_multi
CELERYD_MULTI =$ CELERYD_CHDIR / manage.py celeryd_multi
#如何调用manage.py celeryctl
CELERYCTL =$ CELERYD_CHDIR / manage.py celeryctl
#对celeryd
的额外参数CELERYD_OPTS = - time-limit = 300 --concurrency = 8
芹菜配置模块的名称
CELERY_CONFIG_MODULE =celeryconfig
#%n将被替换为nodename。
CELERYD_LOG_FILE =/ var / log / celery /%n.log
CELERYD_PID_FILE =/ var / run / celery /%n.pid
#作为无特权用户。
CELERYD_USER =芹菜
CELERYD_GROUP =芹菜
#项目设置模块的名称。
export DJANGO_SETTINGS_MODULE =settings
另外我创建了一个文件/etc/init.d / celeryd与我下载的脚本。
现在,当我尝试执行/etc/init.d/celeryd启动它给出错误作为Unrecogonized命令行参数。
我发出celeryd-multi start nodeN作为一个命令,它表示nodeN启动。但是任务执行尚未开始。
我是新进的守护进程和服务器托管。
您可以在主管中运行芹菜:
https://pypi.python。 org / pypi / supervisor
http://thomassileo.com/blog/2012/08/20/how-to-keep-celery-running-with-supervisor/
hth。
On localhost, i used these statements to execute tasks and workers. Run tasks: python manage.py celery beat Run workers: python manage.py celery worker --loglevel=info I used otp, rabbitmq server and django-celery. It is working fine. I uploaded the project on ubuntu server. I would like to daemonize these. For that i created a file /etc/default/celeryd as below config settings.
# Name of nodes to start, here we have a single node
CELERYD_NODES="w1"
# or we could have three nodes:
#CELERYD_NODES="w1 w2 w3"
# Where to chdir at start.
CELERYD_CHDIR="/home/sandbox/myprojrepo/myproj"
# How to call "manage.py celeryd_multi"
CELERYD_MULTI="$CELERYD_CHDIR/manage.py celeryd_multi"
# How to call "manage.py celeryctl"
CELERYCTL="$CELERYD_CHDIR/manage.py celeryctl"
# Extra arguments to celeryd
CELERYD_OPTS="--time-limit=300 --concurrency=8"
Name of the celery config module.
CELERY_CONFIG_MODULE="celeryconfig"
# %n will be replaced with the nodename.
CELERYD_LOG_FILE="/var/log/celery/%n.log"
CELERYD_PID_FILE="/var/run/celery/%n.pid"
# Workers should run as an unprivileged user.
CELERYD_USER="celery"
CELERYD_GROUP="celery"
# Name of the projects settings module.
export DJANGO_SETTINGS_MODULE="settings"
Also i created a file /etc/init.d/celeryd with script i downloaded.
Now when i try to execute /etc/init.d/celeryd start it gives error as Unrecogonized command line argument. I issued "celeryd-multi start nodeN" as a command and it said nodeN started. But tasks execution havent started yet.
I am new to daemonizing and server hosting.
You can run celery within supervisor: https://pypi.python.org/pypi/supervisor http://thomassileo.com/blog/2012/08/20/how-to-keep-celery-running-with-supervisor/
hth.
这篇关于如何在ubuntu服务器上守护django芹菜定期任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!