【发布时间】:2014-11-24 04:04:01
【问题描述】:
这是我的 celery 应用配置:
from __future__ import absolute_import
from celery import Celery
import os
from django.conf import settings
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tshirtmafia.settings')
app = Celery('tshirtmafia')
app.conf.update(
CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend',
)
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
settings.py:
INSTALLED_APPS:
'kombu.transport.django',
'djcelery',
还有:
BROKER_URL = 'django://'
这是我的任务:
@shared_task
def test():
send_mail('nesamone bus', 'Files have been successfully generated.', 'marijus.merkevicius@gmail.com',
['marijus.merkevicius@gmail.com'], fail_silently=False)
现在,当我在本地运行 python manage.py celeryd 然后在本地从 shell 运行 test.delay() 时,它可以工作了。
现在我正在尝试部署我的应用程序。当使用完全相同的配置时,我尝试打开 python manage.py celeryd 并在其他窗口中打开 shell 并运行测试任务,它不起作用。
我也尝试过这样设置后台守护进程:
/etc/default/celeryd 配置:
# 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. (CATMAID Django project dir.)
CELERYD_CHDIR="/home/tshirtnation/"
# Python interpreter from environment. (in CATMAID Django dir)
ENV_PYTHON="/usr/bin/python"
# How to call "manage.py celeryd_multi"
CELERYD_MULTI="$ENV_PYTHON $CELERYD_CHDIR/manage.py celeryd_multi"
# How to call "manage.py celeryctl"
CELERYCTL="$ENV_PYTHON $CELERYD_CHDIR/manage.py celeryctl"
# Extra arguments to celeryd
CELERYD_OPTS="--time-limit=300 --concurrency=1"
# 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"
我使用默认的 celery /etc/init.d/celeryd 脚本。
所以基本上看起来 celeryd 启动但不起作用。不知道如何调试它以及可能出了什么问题。
如果你还需要什么,请告诉我
【问题讨论】:
-
你能把你的日志文件发到
/var/log/celery*.log吗?
标签: python django celery daemon background-process