python - Celery daemon production cannot import Celery error -
i follow instruction of celery docs. first follow this link create production process , here app code.
1-test_celery/celery.py:-
from __future__ import absolute_import import os celery import celery kombu import queue, exchange celery.schedules import crontab import datetime app = celery('test_celery', broker='amqp://jimmy:jimmy123@localhost/jimmy_v_host', backend='rpc://', include=['test_celery.tasks']) # optional configuration, see application user guide. app.conf.update( result_expires=3600, ) if __name__ == '__main__': app.start()
2-test_celery.task.py:-
from __future__ import absolute_import test_celery.celery import app import time kombu import queue, exchange celery.schedules import crontab import datetime app.conf.beat_schedule = { 'planner_1': { 'task': 'test_celery.tasks.printtask', 'schedule': crontab(minute='*/1'), }, } @app.task def printtask(): print 'hello running' time=str(datetime.datetime.now()) file=open('/home/hub9/myproj/data.log','ab') file.write(time) file.close()
3-:my config file /etc/default/celeryd per instructions:
# names of nodes start # start 1 node: #celeryd_nodes="worker1" # can start multiple , configure settings # each in celeryd_opts (see `celery multi --help` examples). celeryd_nodes="worker1 worker2 worker3" # absolute or relative path 'celery' command: celery_bin="/usr/local/bin/celery" #celery_bin="/virtualenvs/def/bin/celery" # app instance use # comment out line if don't use app celery_app="mycelery.test_celery" # or qualified: celery_app="test_celery.celery:app" # chdir @ start. path folder containing task celeryd_chdir="/home/hub9/mycelery/test_celery/" # command-line arguments worker celeryd_opts="--time-limit=3000 --concurrency=3 --config=celeryconfig" # %n replaced first part of nodename. celeryd_log_file="/var/log/celery/%n.log" celeryd_pid_file="/var/run/celery/%n.pid" # workers should run unprivileged user. # need create user manually (or can choose # user/group combination exists, e.g. nobody). celeryd_user="celery" celeryd_group="celery"
** when run sudo service celeryd start production worker starting project gives me error can't import celery module. read answers not able solve problem. ** time
Comments
Post a Comment