[当我尝试启动我的celery / supervisor实例时出现“错误(生成错误)”

问题描述 投票:1回答:1

我已经完成how to use celery on my django production server using supervisor

但是,当我尝试使用sudo supervisorctl start app-celery启动主管时,它会返回:

app-celery: ERROR (spawn error)

这是我的配置/etc/supervisor/conf.d/app-celery.conf

[program:app-celery]
command=/home/zorgan/app/env/bin/celery worker -A draft1 --loglevel=INFO
directory=/home/zorgan/app/draft1

numprocs=1
stdout_logfile=/var/log/supervisor/celery.log
stderr_logfile=/var/log/supervisor/celery.log
autostart=true
autorestart=true
startsecs=10

; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 600

stopasgroup=true

; Set Celery priority higher than default (999)
; so, if rabbitmq is supervised, it will start first.
priority=1000

我已按照教程中的单词逐字逐句地讲-我不知道为什么它不起作用。我已经检查到celery的路径是/home/zorgan/app/env/bin/celery,并且celery.pytasks.py/home/zorgan/app/draft1中。以及/home/zorgan/app/draft1中的初始化文件被更改为:

from __future__ import absolute_import, unicode_literals

#This will make sure the app is always imported when
#Django starts so that shared_task will use this app.
from .celery import app as celery_app

__all__ = ['celery_app']

这是我的celery.py:

import os
from celery import Celery
from celery.schedules import crontab
from .settings import CELERY_BROKER_URL #CELERY_BROKER_URL = 'amqp://174.138.62.649' (changed the number for privacy reasons)

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'draft1.settings')

app = Celery("draft1", broker=CELERY_BROKER_URL)
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()

这里有没有危险信号?因为我的celery.log文件中也出现此错误:

 File "/home/zorgan/app/env/lib/python3.5/site-packages/kombu/utils/imports.py", line 56, in symbol_by_name
    module = imp(module_name, package=package, **kwargs)
  File "/home/zorgan/app/env/lib/python3.5/site-packages/celery/utils/imports.py", line 101, in import_from_cwd
    return imp(module, package=package)
  File "/home/zorgan/app/env/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'draft1'

但是我不确定是否相关。这是我的supervisord.log的摘要:

2018-04-25 03:15:07,665 INFO spawned: 'app-celery' with pid 24296
2018-04-25 03:15:08,050 INFO exited: app-celery (exit status 1; not expected)
2018-04-25 03:15:09,052 INFO gave up: app-celery entered FATAL state, too many start retries too quickly
2018-04-25 03:15:09,815 INFO spawned: 'app-celery' with pid 24302
2018-04-25 03:15:10,221 INFO exited: app-celery (exit status 1; not expected)
2018-04-25 03:15:11,231 INFO spawned: 'app-celery' with pid 24309
2018-04-25 03:15:11,646 INFO exited: app-celery (exit status 1; not expected)
2018-04-25 03:15:13,650 INFO spawned: 'app-celery' with pid 24313
2018-04-25 03:15:14,068 INFO exited: app-celery (exit status 1; not expected)
2018-04-25 03:15:17,074 INFO spawned: 'app-celery' with pid 24317
2018-04-25 03:15:17,505 INFO exited: app-celery (exit status 1; not expected)

知道是什么问题吗?

编辑:

项目树:

home   /   zorgan   /   app   /   draft1
                      ...         ...
                    manage.py  celery.py
                    env        tasks.py
python django unix celery supervisord
1个回答
0
投票

[[program:app-celery]

command = / home / zorgan / app / env / bin / celery worker -A draft1 --loglevel = INFO

目录= / home / zorgan / app

numprocs = 1

stdout_logfile = / var / log / supervisor / celery.log

stderr_logfile = / var / log / supervisor / celery.log

autostart = true

autorestart = true

startsecs = 10

;需要等待当前正在执行的任务在关闭时完成。;如果您的任务运行时间很长,请增加此值。

stopwaitsecs = 600

stopasgroup = true

;将芹菜优先级设置为高于默认值(999);因此,如果对rabbitmq进行监督,它将首先开始。

优先级= 1000

您输入了错误的目录路径该目录将是项目的主目录,而不是设置文件的目录

© www.soinside.com 2019 - 2024. All rights reserved.