首頁>技術>

1 supervisor是什麼

supervisor是一個程式監聽程式,用於將一個程式丟入後臺,並監聽,如果其崩潰則自動啟動

2 supervisor的兩個程式
supervisord:supervisor的守護程式supervisorctl: supervisor shell 程式介面
3 supervisor的安裝
pip install supervisor==4.2.0
4 supervisor配置gunicron
echo_supervisord_conf  > supervisord.confchmod 755 /export/project1/project/gunicorn.sh修改program的部分[program:project1]command = /export/project1/project/gunicorn.sh                    ; Command to start appuser = root                                                     ; User to run asstdout_logfile = /var/log/gunicorn_supervisor.log   ; Where to write log messagesredirect_stderr = true                                                ; Save stderr in the same logenvironment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8                       ; Set UTF-8 as default encoding
5 啟動 supervisord並管理
supervisord -c  supervisord.conf#啟動
管理服務supervisorctl -c  supervisord.conf
6 設定開機啟動
# centos6.7 的supervisord開機啟動指令碼#!/bin/sh## /etc/rc.d/init.d/supervisord## Supervisor is a client/server system that# allows its users to monitor and control a# number of processes on UNIX-like operating# systems.## chkconfig: - 64 36# description: Supervisor Server# processname: supervisord# Source init functions. /etc/rc.d/init.d/functionsprog="supervisord"prefix="/export/django-test/django-test2"exec_prefix="${prefix}"prog_bin="${exec_prefix}/bin/supervisord"  #修改為supervisord位置PIDFILE="/var/run/$prog.pid"configfile="${prefix}/test.conf"#s修改為upervisord配置檔案位置 start(){        echo -n $"Starting $prog: "        daemon $prog_bin -c $configfile --pidfile $PIDFILE        [ -f $PIDFILE ] && success $"$prog startup" || failure $"$prog startup"        echo}stop(){        echo -n $"Shutting down $prog: "        [ -f $PIDFILE ] && killproc $prog || success $"$prog shutdown"        echo}case "$1" in  start)    start  ;;  stop)    stop  ;;  status)        status $prog  ;;  restart)    stop    start  ;;  *)    echo "Usage: $0 {start|stop|restart|status}"  ;;esacchmod 755 supervisord # 2.設定開機啟動chkconfig --add supervisordchkconfig supervisord on

14
最新評論
  • BSA-TRITC(10mg/ml) TRITC-BSA 牛血清白蛋白改性標記羅丹明
  • 程式設計師刷題指南-兩數之和