supervisor

安装

http://www.supervisord.org/installing.html

1
pip install supervisor

status

1
2
3
4
5
6
7
❯ supervisorctl -c /opt/supervisor/supervisord.conf  status
spug-api BACKOFF Exited too quickly (process log may have details)
spug-monitor RUNNING pid 8505, uptime 0:00:05
spug-scheduler RUNNING pid 8506, uptime 0:00:05
spug-worker RUNNING pid 8507, uptime 0:00:05
spug-ws BACKOFF Exited too quickly (process log may have details)

stop

1
supervisorctl stop all

FATAL & BACKOFF

Exited too quickly (process log may have details) 反复执行会复现,执行太快

2024-08-04 16:39:32,933 WARN exited: spug-api (exit status 0; not expected)
2024-08-04 16:39:32,948 WARN exited: spug-ws (exit status 0; not expected)

脚本有判断exit 0

[ “$num” -eq 0 ] || { echo “runing….” && exit 0 ;}

exec gunicorn -b 127.0.0.1:8000 -w 2 –threads 8 –access-logfile - spug.wsgi

修改为

num=$(ps -ef | grep “/opt/tools/spug-3.0/spug_api/venv/bin/python3.9 /opt/tools/spug-3.0/spug_api/venv/bin/gunicorn” | grep -v grep | wc -l)
[ “$num” -eq 0 ] && {
echo “start runing….”
exec gunicorn -b 127.0.0.1:8000 -w 2 –threads 8 –access-logfile - spug.wsgi
}

supervisor 停止时,gunicorn运行状态

pids=$( ps -ef | grep “/opt/tools/spug-3.0/spug_api/venv/bin/python3.9 /opt/tools/spug-3.0/spug_api/venv/bin/gunicorn” | grep -v grep | awk ‘{print $2}’ | tr ‘\n’ ‘ ‘ )

[ -z “$pids” ] || { echo “runing …$pids” && kill -9 $pids ;}

exec gunicorn -b 127.0.0.1:8000 -w 2 –threads 8 –access-logfile - spug.wsgi

点击打赏
文章目录
  1. 1. 安装
    1. 1.1. status
    2. 1.2. stop
    3. 1.3. FATAL & BACKOFF
载入天数...载入时分秒... ,