一、单纯的celery项目(异步+定时)
1 [program:jj-celery-worker] 2 command=celery -A main.app worker --loglevel=info 3 directory=/data/pyshell/bi/celery-app 4 environment=PATH="/home/opt/jj_celery/bin" 5 user=opt 6 autostart=true 7 autorestart=true 8 stdout_logfile=/data/pyshell/bi/celery-app/logs/worker_supervisor.log 9 stderr_logfile=/data/pyshell/bi/celery-app/logs/worker_supervisor_err.log 10 #startsecs=10 11 #stopwaitsecs=20 12 13 [program:jj-celery-beat] 14 command=celery -A main.app beat --loglevel=info 15 directory=/data/pyshell/bi/celery-app 16 environment=PATH="/home/opt/jj_celery/bin" 17 user=opt 18 autostart=true 19 autorestart=true 20 stdout_logfile=/data/pyshell/bi/celery-app/logs/beat_supervisor.log 21 stderr_logfile=/data/pyshell/bi/celery-app/logs/beat_supervisor_err.log 22 #startsecs=10 23 #stopwaitsecs=20 24 25 [group:jj-celery] 26 programs=jj-celery-beat,jj-celery-worker
二、Flask项目中增加celery功能(异步)
1 [program:game_24_uwsgi] 2 command= /root/calc24/bin/uwsgi /data/project/game_24/uwsgi.ini 3 numprocs=1 ; 启动1个进程 4 directory=/data/project/game_24/game_24_web ; 执行前先cd到目录去 5 priority=999 ; the relative start priority (default 999) 6 autostart=true ; start at supervisord start (default: true) 7 autorestart=true ; retstart at unexpected quit (default: true) 8 stopasgroup=true ; send stop signal to the UNIX process group (default false) 9 killasgroup=true ; SIGKILL the UNIX process group (def false) 10 startsecs=10 ; number of secs prog must stay running (def. 10) 11 startretries=10 ; max # of serial start failures (default 3) 12 exitcodes=0,2 ; 'expected' exit codes for process (default 0,2) 13 stopsignal=QUIT ; signal used to kill proce conftopwaitsecs=10 ; max num secs to wait before SIGKILL (default 10) 14 user=root ; setuid to this UNIX account to run the program 15 log_stdout=true ; if true, log program stdout (default true) 16 log_stderr=true ; if true, log program stderr (def false) 17 stdout_logfile=/tmp/game_24.log ; child log path, use NONE for none; default AUTO 18 logfile_maxbytes=10MB ; max # logfile bytes b4 rotation (default 50MB) 19 logfile_backups=10 ; # of logfile backups (default 10) 20 environment= 21 MODE="TESTING", 22 FLASK_ENV="development" 23 24 [program:game_24_celery] 25 command=celery -A tasks.celery worker --loglevel=info 26 directory=/data/project/game_24/game_24_web 27 environment=PATH="/root/calc24/bin" 28 user=root 29 autostart=true 30 autorestart=true 31 stdout_logfile=/data/project/game_24/logs/uwsgi_supervisor.log 32 stderr_logfile=/data/project/game_24/logs/uwsgi_supervisor_err.log 33 #startsecs=10 34 #stopwaitsecs=20 35 36 37 [group:game_24] 38 programs=game_24_uwsgi,game_24_celery