芹菜和Django,伐木芹菜

时间:2012-04-20 10:27:47

标签: django nginx virtualenv celery django-celery

我正在用django经营芹菜,并且在开发方面表现很好。但现在我想让它活下去 在我的生产服务器上,我遇到了一些问题。

我的设置如下:

  • Ubuntu的
  • Nginx的
  • Vitualenv
  • 新贵
  • Gunicorn
  • Django的

我不知道如何在用upstart开始使用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

3 个答案:

答案 0 :(得分:3)

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

  

CELERYD_LOG_FILE = “/变种/数/芹菜/%n.log”

其中%s将被节点名称

替换

答案 1 :(得分:2)

您可以使用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

现在通过在终端输入supervisord启动主管,芹菜将根据您上面的设置自动启动。

答案 2 :(得分:1)

你可以运行:

python manage.py celery worker

如果djcelery

中有INSTALLED_APPS,这将有效