uwsgi错误:“芹菜:未找到”,芹菜在带有Attach-daemon2的venv中运行

时间:2019-06-27 17:27:19

标签: celery virtualenv uwsgi django-celery

如果我在django应用的虚拟环境中手动运行celery,那么它将起作用:

filteredItems

但是我无法使其与uwsgi的(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. 一起运行:

attach-daemon2

我的uwsgi日志给我这个错误:

#hackerspace_uwsgi.ini
[uwsgi]
...
attach-daemon2  = cmd=%(chdir)/celery -A hackerspace_online worker -l info -c 3 -Q default

似乎表明它不是在虚拟环境中运行。如何让uwsgi运行celery,使其像手动运行时一样工作?

1 个答案:

答案 0 :(得分:0)

uwsgi docs说要使用smart-attach-daemon和pidfile尝试此操作。芹菜本身建议使用multi to start workers when daemonizing

[uwsgi]
master = true
socket = :3031
smart-attach-daemon = /tmp/celery.pid celery -A tasks worker --pidfile=/tmp/celery.pid