【发布时间】:2019-06-27 17:27:19
【问题描述】:
如果我在我的 django 应用程序的虚拟环境中手动运行 celery,它可以工作:
(hackerspace) 90158@hackerspace:~/hackerspace/src$ celery -A hackerspace_online worker -l info -c 3 -Q default
-------------- celery@hackerspace v4.3.0 (rhubarb)
---- **** -----
--- * *** * -- Linux-4.4.0-151-generic-x86_64-with-Ubuntu-16.04-xenial 2019-06-27 10:19:53
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: hackerspace_online:0x7f8ecb7dbba8
- ** ---------- .> transport: redis://127.0.0.1:6379/0
- ** ---------- .> results:
- *** --- * --- .> concurrency: 3 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [queues]
.> default exchange=default(direct) key=default
[tasks]
. hackerspace_online.celery.debug_task
. update_conditions_for_quest
. update_quest_conditions_all
. update_quest_conditions_for_user
[2019-06-27 10:19:53,439: INFO/MainProcess] Connected to redis://127.0.0.1:6379/0
[2019-06-27 10:19:53,447: INFO/MainProcess] mingle: searching for neighbors
[2019-06-27 10:19:54,466: INFO/MainProcess] mingle: all alone
[2019-06-27 10:19:54,482: INFO/MainProcess] celery@hackerspace ready.
但我无法让它与 uwsgi 的 attach-daemon2 一起运行:
#hackerspace_uwsgi.ini
[uwsgi]
...
attach-daemon2 = cmd=%(chdir)/celery -A hackerspace_online worker -l info -c 3 -Q default
我的 uwsgi 日志给了我这个错误:
[uwsgi-daemons] respawning "/home/90158/hackerspace/src/celery -A hackerspace_online worker -l info -c 3 -Q default" (uid: 33 gid: 33)
/bin/sh: 1: /home/90158/hackerspace/src/celery: not found
这似乎表明它不是在虚拟环境中运行的。如何让 uwsgi 运行 celery,使其像手动运行时一样工作?
【问题讨论】:
标签: celery virtualenv uwsgi django-celery