我有一个Django应用程序(名为pcycler),我需要与芹菜一起运行。我正试图将其部署到生产中。
我得到一个错误,当我运行:
monitorctl start芹菜
这给了我:
芹菜:ERROR(异常终止)
这是我的celery.conf文件,它包含在monitor .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
我得到的错误与错误日志中的错误完全相同!这导致我假设当我运行在supervisor时,目录没有被正确更改。
tldr:为什么当我使用superorctl运行命令时,我的supervisor.conf中的目录没有被应用?
发现了错误,原来真的很傻
上级配置文件是特定于订单的,所以这样做:
[program:celery]
directory=/webapps/pcyclerenv/pcycler
command=/webapps/pcyclerenv/bin/celery -A pcycler worker -l info
(... the rest ..)
解决了我的问题。