我有一个需要与Celery一起运行的Django应用程序(名为pcycler)。我正在尝试使用Supervisor在生产中部署它。
我跑步时收到错误:
supervisorctl start celery
这给了我:
芹菜:错误(异常终止)
这是我的celery.conf文件,该文件包含在start。的supervisor.conf中。
[program:celery]
command=/webapps/pcyclerenv/bin/celery -A pcycler worker -l info
directory=/webapps/pcyclerenv/pcycler
user=pcycleruser
numprocs=1
stdout_logfile=/webapps/pcyclerenv/logs/celeryd_stdout.log
stderr_logfile=/webapps/pcyclerenv/logs/celeryd_stderr.log
redirect_stderr=false
autostart=true
autorestart=true
startsecs=10
stopwaitsecs=600
killasgroup=true
priority=998
celeryd_stderr.log的内容是:
Traceback (most recent call last):
File "/webapps/pcyclerenv/bin/celery", line 11, in <module>
sys.exit(main())
File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/__main__.py", line 30, in main
main()
File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 81, in main
cmd.execute_from_commandline(argv)
File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 769, in execute_from_commandline
super(CeleryCommand, self).execute_from_commandline(argv)))
File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/bin/base.py", line 304, in execute_from_commandline
argv = self.setup_app_from_commandline(argv)
File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/bin/base.py", line 464, in setup_app_from_commandline
self.app = self.find_app(app)
File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/bin/base.py", line 484, in find_app
return find_app(app, symbol_by_name=self.symbol_by_name)
File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/app/utils.py", line 222, in find_app
sym = symbol_by_name(app, imp=imp)
File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/bin/base.py", line 487, in symbol_by_name
return symbol_by_name(name, imp=imp)
File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/kombu/utils/__init__.py", line 92, in symbol_by_name
module = imp(module_name, package=package, **kwargs)
File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/utils/imports.py", line 101, in import_from_cwd
return imp(module, package=package)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named pcycler
当然,我决定自己运行这个程序,看看我是否可以复制这个错误:
pcycleruser@raspberrypi:/webapps/pcyclerenv/pcycler$ pwd
/webapps/pcyclerenv/pcycler
pcycleruser@raspberrypi:/webapps/pcyclerenv/pcycler$ /webapps/pcyclerenv/bin/celery -A pcycler worker -l info
(... text and pickle deprecation warnings ...)
[2014-05-23 14:52:36,053: WARNING/MainProcess] /webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/fixups/django.py:233: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments!
warnings.warn('Using settings.DEBUG leads to a memory leak, never '
[2014-05-23 14:52:36,066: WARNING/MainProcess] celery@raspberrypi ready.
这样有效。但是,当我在错误的目录中时,如下所示:
pcycleruser@raspberrypi:/webapps/pcyclerenv/pcycler$ cd ..
pcycleruser@raspberrypi:/webapps/pcyclerenv$ pwd
/webapps/pcyclerenv
pcycleruser@raspberrypi:/webapps/pcyclerenv$ /webapps/pcyclerenv/bin/celery -A pcycler worker -l info
Traceback (most recent call last):
File "/webapps/pcyclerenv/bin/celery", line 11, in <module>
sys.exit(main())
File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/__main__.py", line 30, in main
main()
(... exact same error as above ...)
ImportError: No module named pcycler
我得到与错误日志中完全相同的错误!这使我假设当我在主管中运行时,目录没有被正确更改。
tldr :当我使用supervisorctl运行命令时,为什么我的supervisor.conf中的目录没有被应用?
答案 0 :(得分:7)
发现错误,真的哑。
主管conf文件是特定于订单的,所以:
[program:celery]
directory=/webapps/pcyclerenv/pcycler
command=/webapps/pcyclerenv/bin/celery -A pcycler worker -l info
(... the rest ..)
解决我遇到的问题。