我曾经将我所有的Flask应用程序代码和芹菜代码放在一个文件中,它与supervisor一起工作得很好。然而,它是非常复杂的,所以我将我的任务分配给celery_tasks.py,然后这个问题就发生了。
在我的项目目录中,我可以使用以下命令手动启动celery
celery -A celery_tasks worker --loglevel=INFO但是,因为这是一台服务器,所以我需要celery在后台作为守护进程运行。但当我调用sudo supervisorctl restart celeryd时,它显示以下错误
celeryd: ERROR (abnormal termination)日志上写着:
Traceback (most recent call last):
File "/srv/www/learningapi.stanford.edu/peerAPI/peerAPIenv/bin/celery", line 9, in <module>
load_entry_point('celery==3.0.19', 'console_scripts', 'celery')()
File "/srv/www/learningapi.stanford.edu/peerAPI/peerAPIenv/local/lib/python2.7/site-packages/celery/__main__.py", line 14, in main
main()
File "/srv/www/learningapi.stanford.edu/peerAPI/peerAPIenv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 957, in main
cmd.execute_from_commandline(argv)
File "/srv/www/learningapi.stanford.edu/peerAPI/peerAPIenv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 901, in execute_from_commandline
super(CeleryCommand, self).execute_from_commandline(argv)))
File "/srv/www/learningapi.stanford.edu/peerAPI/peerAPIenv/local/lib/python2.7/site-packages/celery/bin/base.py", line 185, in execute_from_commandline
argv = self.setup_app_from_commandline(argv)
File "/srv/www/learningapi.stanford.edu/peerAPI/peerAPIenv/local/lib/python2.7/site-packages/celery/bin/base.py", line 300, in setup_app_from_commandline
self.app = self.find_app(app)
File "/srv/www/learningapi.stanford.edu/peerAPI/peerAPIenv/local/lib/python2.7/site-packages/celery/bin/base.py", line 318, in find_app
return sym.celery
AttributeError: 'module' object has no attribute 'celery'我使用了以下配置。
[program:celeryd]
command = celery -A celery_tasks worker --loglevel=INFO
user=peerapi
numprocs=4
stdout_logfile = <path to log>
stderr_logfile = <path to log>
autostart = true
autorestart = true
environment=PATH="<path to my project>"
startsecs=10
; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 600
; 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我的代码还正确地初始化了celery
celery = Celery('celery_tasks', broker='amqp://guest:guest@localhost:5672//',
backend='amqp')
celery.config_from_object(celeryconfig)我的celeryconfig.py工作正常
CELERY_TASK_SERIALIZER='json'
CELERY_RESULT_SERIALIZER='json'
CELERY_TIMEZONE='America/Los Angeles'
CELERY_ENABLE_UTC=True有什么线索吗?
发布于 2013-07-25 20:03:07
看起来你的应用程序找不到你的celeryconfig,这是因为你的CWD没有被设置。尝试使用下面的内容: cd app_path;celeryd ...此外,您还需要设置环境
# local settings
PATH=/home/ubuntu/envs/app/bin:$PATH
PYTHONHOME=/home/ubuntu/envs/app/
PYTHONPATH=/home/ubuntu/projects/app/应该行得通。
https://stackoverflow.com/questions/17007101
复制相似问题