2

我正在用 django 运行 celery,并且在开发中效果很好。但是现在我想让它在我的生产服务器上运行,我遇到了一些问题。

我的设置如下:

  • Ubuntu
  • Nginx
  • 虚拟环境
  • 暴发户
  • 独角兽
  • 姜戈

我不确定现在如何用 django 启动芹菜,当用暴发户启动它时,它在哪里登录?

我在这里开始 django:

~$ cd /var/www/webapps/minamobime_app
~$ source ../bin/activate

执行 /var/www/webapps/bin/gunicorn_django -w $NUM_WORKERS \ --user=$USER --group=$GROUP --bind=$IP:$P​​ORT --log-level=debug \ --log-file =$LOGFILE 2>>$LOGFILE

我如何开始芹菜?

exec python manage.py celeryd -E -l info -c 2
4

3 回答 3

3

考虑将 celery 配置为daemon。对于日志记录:

CELERYD_LOG_FILE="/var/log/celery/%n.log"

其中 %s 将替换为节点名称

于 2012-04-20T10:33:54.290 回答
2

您可以使用 apt-get 安装主管,然后您可以将以下内容添加到名为 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

现在通过在终端中输入 supervisord 来启动主管,celery 将根据您上面所做的设置自动启动。

于 2014-12-09T17:40:38.913 回答
1

你可以运行:

python manage.py celery worker

如果你有djcelery你的INSTALLED_APPS

于 2016-03-10T20:17:20.787 回答