Python 3.x 在centos 7上使用systemd对芹菜进行监控
我打算使用systemd作为守护进程运行芹菜4.3.0,但它给了我以下错误: 它启动了工人,但很快就阻止了他们。但是,我可以通过键入以下命令手动运行worker:Python 3.x 在centos 7上使用systemd对芹菜进行监控,python-3.x,celery,centos7,daemon,Python 3.x,Celery,Centos7,Daemon,我打算使用systemd作为守护进程运行芹菜4.3.0,但它给了我以下错误: 它启动了工人,但很快就阻止了他们。但是,我可以通过键入以下命令手动运行worker: 芹菜-一个bin.proj.芹菜\u应用程序工作人员1 这是芹菜。服务: [Unit] Description=Celery Service After=network.target [Service] type=forking User=ssc Group=ssc EnvironmentFile=/etc/conf/celer
- 芹菜-一个bin.proj.芹菜\u应用程序工作人员1
[Unit]
Description=Celery Service
After=network.target
[Service]
type=forking
User=ssc
Group=ssc
EnvironmentFile=/etc/conf/celery
WorkingDirectory=/home/ssc/Mr.Robot/
ExecStart=/bin/sh -c '${CELERY_BIN} multi start ${CELERYD_NODES} -A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} --logfile=${CELERYD_LOG_FILE} ${CELERYD_OPTS}'
ExecStop=/bin/sh -c '${CELERY_BIN} multi stopwait ${CELERYD_NODES} --pidfile=${CELERYD_PID_FILE}'
ExecReload=/bin/sh -c '${CELERY_BIN} restart ${CELERYD_NODES} -A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} --logfile=${CELERYD_LOG_FILE} ${CELERYD_OPTS}'
[Install]
WantedBy=multi-user.target
以下是关联的配置文件:
# Name of nodes to start
# here we have a single node
#CELERYD_NODES="w1"
# or we could have three nodes:
CELERYD_NODES="worker1 worker2 worker3"
# Absolute or relative path to the 'celery' command:
CELERY_BIN="/usr/local/bin/celery"
#CELERY_BIN="/virtualenvs/def/bin/celery"
# App instance to use
# comment out this line if you don't use an app
CELERY_APP="bin.proj.celery_app"
# or fully qualified:
#CELERY_APP="proj.tasks:app"
# How to call manage.py
CELERYD_MULTI="multi"
# Extra command-line arguments to the worker
CELERYD_OPTS="--loglevel=INFO --time-limit=300 --concurrency=3"
# - %n will be replaced with the first part of the nodename.
# - %I will be replaced with the current child process index
# and is important when using the prefork pool to avoid race conditions.
CELERYD_PID_FILE="/var/run/celery/%n.pid"
CELERYD_LOG_FILE="/var/log/celery/%n%I.log"
CELERYD_LOG_LEVEL="INFO"
# you may wish to add these options for Celery Beat
CELERYBEAT_PID_FILE="/var/run/celery/beat.pid"
CELERYBEAT_LOG_FILE="/var/log/celery/beat.log"
和应用程序文件:
import sys,os
sys.path.append(os.getcwd())
from celery import Celery
from bin.proj.utils import create_rotating_log
# initialize logger
global logger
logger = create_rotating_log('./log/activity.log')
# initialize celery
try:
app = Celery('celery_app',
broker="".join(['redis://:pass@localhost:6379/10']),
backend="".join(['redis://:pass@localhost:6379/11']),
include=['bin.proj.tasks'])
#logger.info('Celery session OK')
except Exception as e:
logger.error('Celery session KO')
logger.error(e)
if __name__ == '__main__':
app.start()
该用户是“ssc”,该用户不是根组的一部分,我为“ssc”用户授予了该项目所需的所有权利。
任何帮助都将不胜感激,我已经在上面花费了太多时间,谢谢嘿,你解决了这个问题吗?芹菜守护进程设置是绝对皮塔为我每次。如果你能分享答案,我会很有帮助的。
import sys,os
sys.path.append(os.getcwd())
from celery import Celery
from bin.proj.utils import create_rotating_log
# initialize logger
global logger
logger = create_rotating_log('./log/activity.log')
# initialize celery
try:
app = Celery('celery_app',
broker="".join(['redis://:pass@localhost:6379/10']),
backend="".join(['redis://:pass@localhost:6379/11']),
include=['bin.proj.tasks'])
#logger.info('Celery session OK')
except Exception as e:
logger.error('Celery session KO')
logger.error(e)
if __name__ == '__main__':
app.start()