我正在用django运行芹菜,并且在开发中工作得很好。但现在我想让它活起来在我的生产服务器上,我遇到了一些问题。
我的设置如下:
- 乌班图
- 恩金克斯
- 维图阿伦夫
- 暴发户
- 独角兽
- 姜戈
我不确定现在如何在用 django 启动芹菜时启动它,它在哪里登录?
我在这里开始 django:
~$ cd /var/www/webapps/minamobime_app
~$ source ../bin/activate
exec/var/www/webapps/bin/gunicorn_django -w $NUM_WORKERS \ --user=$USER --group=$GROUP --bind=$IP:$PORT --log-level=debug \ --log-file=$LOGFILE 2>>$LOGFILE
如何开始芹菜?
exec python manage.py celeryd -E -l info -c 2
考虑将芹菜配置为守护进程。对于日志记录特定:
CELERYD_LOG_FILE="/var/log/celery/%n.log"
其中 %s 将替换为节点名称
apt-get安装supervisor,然后您可以将以下内容添加到名为celeryd.conf的文件(或您想要的任何名称)到etc/supervisor/conf.d文件夹(如果不存在,请创建conf.d文件夹)
; ==================================
; celery worker supervisor example
; ==================================
[program:celery]
; Set full path to celery program if using virtualenv
command=/home/<path to env>/env/bin/celery -A <appname> worker -l info
;enter the directory in which you want to run the app
directory=/home/<path to the app>
user=nobody
numprocs=1
stdout_logfile=/home/<path to the log file>/worker.log
stderr_logfile=/home/<path to the log file>/worker.log
autostart=true
autorestart=true
startsecs=10
; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 1000
; When resorting to send SIGKILL to the program to terminate it
; send SIGKILL to its whole process group instead,
; taking care of its children as well.
killasgroup=true
; if rabbitmq is supervised, set its priority higher
; so it starts first
priority=998
同时将以下行添加到 etc/supervisor/supervisord.conf
[include]
files = /etc/supervisor/conf.d/*.conf
现在通过在终端中键入主管来启动主管,芹菜将根据您上面所做的设置自动启动。
您可以运行:
python manage.py celery worker
如果您的INSTALLED_APPS
中有djcelery
,这将起作用