2014-09-29 46 views
0

這裏是我的芹菜應用程序配置:Django的芹菜守護程序不起作用

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.', '[email protected]', 
    ['[email protected]'], fail_silently=False) 

現在,我在本地運行本地python manage.py celeryd,然後從本地運行test.delay(),它可以工作。

現在我試圖部署我的應用程序。當使用完全相同的配置時,我嘗試打開python manage.py celeryd,並在其他窗口中打開shell並運行測試任務,但它不起作用。

我也試着設置後臺守護進程是這樣​​的:

的/ etc /默認/ 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" 

我使用默認的芹菜/etc/init.d/celeryd腳本。

所以基本上它看起來像芹菜開始,但不起作用。不知道如何調試,可能是錯誤的。

讓我知道,如果你有什麼事

+0

你可以在'/ var/log/celery * .log'上發佈你的日誌文件嗎? – ChillarAnand 2014-09-30 10:51:59

回答

1

芹菜原來是在Django強大的系統非常任性孩子一樣對我。 對於瞭解問題的原因,初始數據太少。 Celery守護程序最常見的原因是文件系統權限。 但要澄清我想嘗試的原因:從Django項目的用戶所有者命令行

  1. 開始芹菜:

    芹菜-A凸出工人-l信息

如果它工作正常,再進一步

  • 開始CELER Ÿ在口頭模式作爲根用戶,就像守護進程是:

    須藤SH -x /etc/init.d/celeryd開始

  • 這將顯示大多數與問題守護進程腳本 - 芹菜用戶和組使用,但不是全部,不幸的是:權限失敗不可見。

    我的小話。 通常芹菜是由自己的芹菜用戶啓動的,並由另一個django項目啓動。經過長期的戰鬥芹菜和系統,我拒絕了芹菜使用者,並由django項目用戶擁有芹菜過程。

    和..不要忘記再次啓動

    update-rc.d celerybeat defaults 
    update-rc.d celeryd defaults 
    

    這是Ubuntu的守護啓動,確保萬無一失。

    祝你好運