Python 芹菜打浆在生产中的应用

Python 芹菜打浆在生产中的应用,python,celery,supervisord,celerybeat,Python,Celery,Supervisord,Celerybeat,我试图运行芹菜击败从我的虚拟环境使用主管。脚本似乎不起作用 我的所有主管脚本都在目录/etc/supervisord 它有一个supervisord.conf文件和目录conf.d,其中包含文件Gorgon Cellery.conf 我的supervisord.conf文件如下所示: [unix_http_server] file=/tmp/supervisor.sock ; (the path to the socket file) [supervisord] logfile=/var/

我试图运行芹菜击败从我的虚拟环境使用主管。脚本似乎不起作用

我的所有主管脚本都在目录
/etc/supervisord
它有一个
supervisord.conf
文件和目录
conf.d
,其中包含文件
Gorgon Cellery.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
[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
我的
Gorgon芹菜.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
[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-supervisordc/etc/supervisord/supervisordconf

尝试替换

command=cd /home/sourabh_workaholic_gmail_com/sites/source && source ../virtualenv/bin/activate && celery -A Gorgon beat --max-interval=10

现在在
script.sh
中输入以下内容:

#!/bin/bash    
cd /home/sourabh_workaholic_gmail_com/sites/source 
source ../virtualenv/bin/activate 
celery -A Gorgon beat --max-interval=10

我怀疑您不能将
source
命令与supervisorctl一起使用,因为它不会在shell中执行您的命令字符串
source
是bash shell提供的一个命令,因此我们将这些命令放在一个
bash
脚本中它们将工作的地方。

当我使用命令
ps aux | grep芹菜
时,我得到的输出是:1001 23882 0.0.3 10468 2184 pts/2 S+14:37 0:00 grep--color=auto芹菜它在监管者之外工作吗?例如,如果你将
command=cd/home/sourabh\u workaholic\u gmail\u com/sites/source&&source../virtualenv/bin/activate&&cellery-A Gorgon-beat-max interval=10
粘贴到shell中。是的,它确实可以完美地工作。它似乎起到了作用,但我刚刚发现了一个新的缺陷。第二个脚本似乎只运行celerybeat并跳过celery。您需要创建两个单独的bash脚本。一个是芹菜,一个是芹菜酱,是我做的。通过这种方式,我得到的输出是:
ps aux|grep芹菜
root 24523 0.0 0.6 67904 4188 pts/2 T 14:50 0:00 sudo nano Gorgon芹菜.conf
root 24524 0.0 0 0.7 14604 4704 pts/2 T 14:50 0:00 nano Gorgon芹菜.conf
root 24620 0.1 7.6 174784 45968?S 14:52 0:00/home/sourabh_workaholic_gmail_com/sites/virtualenv/bin/python/home/sourabh_workaholic_gmail_com/sites/virtualenv/bin/celery-A Gorgon beat-max interval=10最大间隔时间=100125246 0.0.3 10468 2136分/2秒+15:01 0:00 grep--color=auto芹菜,它只是跳过并运行celerybeat。我正在使用“nohup芹菜-一个蛇发女工&”命令来运行它。