我正在尝试使用主管从虚拟环境运行芹菜节拍。该脚本似乎不起作用
我所有的主管脚本都在目录/etc/supervisord
中
它有一个supervisord.conf
文件和目录conf.d
,其中包含文件Gorgon-celery.conf
我的supervisord.conf
文件如下所示:
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
[supervisord]
logfile=/var/log/supervisord/main.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
childlogdir=/var/log/supervisord ; ('AUTO' child log dir, default $TEMP)
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
[include]
files = /etc/supervisord/conf.d/*.conf
我的
Gorgon-celery.conf
文件如下所示:[program:Gorgon-celery]
command=cd /home/ubuntu/sites/source && source ../virtualenv/bin/activate && celery -A Gorgon worker
environment=PYTHONPATH=/home/ubuntu/sites/virtualenv/bin
directory=/home/ubuntu/sites/source
numprocs=1
stdout_logfile=/var/log/celeryd/Gorgon.log
stderr_logfile=/var/log/celeryd/Gorgon.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 600
[program:Gorgon-celerybeat]
command=cd /home/ubuntu/sites/source && source ../virtualenv/bin/activate && celery -A Gorgon beat --max-interval=10
environment=PYTHONPATH=/home/ubuntu/sites/virtualenv/bin
directory=/home/ubuntu/sites/source
numprocs=1
stdout_logfile=/var/log/celeryd/Gorgon-beat.log
stderr_logfile=/var/log/celeryd/Gorgon-beat.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 600
最后,对主管,我正在使用以下命令:
sudo supervisord -c /etc/supervisord/supervisord.conf
最佳答案
尝试更换
command=cd /home/sourabh_workaholic_gmail_com/sites/source && source ../virtualenv/bin/activate && celery -A Gorgon beat --max-interval=10
与
command=bash /home/sourabh_workaholic_gmail_com/script.sh
现在放在
script.sh
中,并输入以下内容:#!/bin/bash
cd /home/sourabh_workaholic_gmail_com/sites/source
source ../virtualenv/bin/activate
celery -A Gorgon beat --max-interval=10
我怀疑您不能将
source
命令与超级用户一起使用,因为它不会在shell中执行命令字符串。 source
是bash shell提供的命令,因此我们将命令放在bash
脚本中,它们将在其中运行。关于python - celery 在生产中使用主管打败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29946838/