python:supervisor

文書の過去の版を表示しています。


Supervisor - プロセス制御システム

dnf

$ sudo dnf install supervisor

pip

$ sudo pip3 install supervisor
Collecting supervisor
  Downloading https://files.pythonhosted.org/packages/a5/27/03ee384818f4fc5f678743bb20ac49c5b4fc9f531bd404dec4b61a8b5d42/supervisor-4.0.4-py2.py3-none-any.whl (296kB)
     |████████████████████████████████| 307kB 1.9MB/s
Collecting meld3>=1.0.0 (from supervisor)
  Downloading https://files.pythonhosted.org/packages/b6/ae/e6d731e4b9661642c1b20591d8054855bb5b8281cbfa18f561c2edd783f7/meld3-1.0.2-py2.py3-none-any.whl
Installing collected packages: meld3, supervisor
Successfully installed meld3-1.0.2 supervisor-4.0.4
$ sudo systemctl enable supervisord.service
$ sudo vi /etc/supervisord.conf
;[unix_http_server]
;file=/var/run/supervisor/supervisor.sock   ; (the path to the socket file)
 
[inet_http_server]         ; inet (TCP) server disabled by default
port=127.0.0.1:9001        ; (ip_address:port specifier, *:port for all iface)

古い資料です

$ sudo pip install supervisor
sudo vi /etc/init.d/supervisord
#!/bin/bash
#
# supervisord  Startup script for the Supervisor
#
# chkconfig: - 70 60
# description: Supervisor is a client/server system that allows its users to \
#              monitor and control a number of processes on UNIX-like operating systems.
# processname: supervisord
# config:  /etc/sysconfig/supervisord
# pidfile: /var/run/supervisord/supervisord.pid
#
### BEGIN INIT INFO
# Provides: supervisord
# Short-Description: start and stop Supervisor
# Description: Supervisor is a client/server system that allows its users to
#  monitor and control a number of processes on UNIX-like operating systems.
### END INIT INFO
 
# Source function library.
. /etc/rc.d/init.d/functions
 
if [ -f /etc/sysconfig/supervisord ]; then
    . /etc/sysconfig/supervisord
fi
 
supervisord=${SUPERVISORD-/usr/bin/supervisord}
prog=supervisord
pidfile=${PIDFILE-/var/run/supervisor/supervisor.pid}
lockfile=${LOCKFILE-/var/lock/subsys/supervisord}
RETVAL=0
STOP_TIMEOUT=${STOP_TIMEOUT-3}
 
start() {
    echo -n $"Starting $prog: "
    daemon $supervisord --pidfile=${pidfile}
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch ${lockfile}
    return $RETVAL
}
 
stop() {
    echo -n $"Stopping $prog: "
    killproc -p ${pidfile} -d ${STOP_TIMEOUT} $supervisord -QUIT
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
 
reload() {
    echo -n $"Reloading $prog: "
    killproc -p $pidfile $supervisord -HUP
    RETVAL=$?
    echo
}
 
# See how we were called.
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status -p ${pidfile} $supervisord
        RETVAL=$?
        ;;
    restart)
        stop
        start
        ;;
    reload)
        reload
        ;;
    *)
        echo $"Usage: $prog {start|stop|restart|reload|status}"
        RETVAL=2
esac
 
exit $RETVAL

rc スクリプトのパーミッション設定を行う。

$ sudo chmod 755 /etc/init.d/supervisord

pid、logファイルの生成ディレクトリを作成する。

$ sudo mkdir /var/run/supervisord
$ sudo mkdir /var/log/supervisord

サービスを登録する。

$ sudo chkconfig --add supervisord
$ sudo chkconfig supervisord on
$ chkconfig --list supervisord
supervisord    	0:off	1:off	2:on	3:on	4:on	5:on	6:off

設定ファイルを生成する。

$ sudo sh -c 'echo_supervisord_conf > /etc/supervisord.conf'
sudo vi /etc/supervisord.conf
[unix_http_server]
;file=/tmp/supervisor.sock  ; (the path to the socket file)
;chmod=0700                 ; socket file mode (default 0700)
;chown=nobody:nogroup       ; socket file uid:gid owner
file=/var/run/supervisord/supervisord.sock
chmod=0666
chown=nobody:nobody

[supervisord]
;logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile=/var/log/supervisord/supervisord.log
;pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
pidfile=/var/run/supervisord/supervisord.pid

[supervisorctl]
;serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket
serverurl=unix:///var/run/supervisord/supervisord.sock

;[include]
;files = relative/directory/*.ini
[include]
files = supervisor.d/*.ini

プロセス設定を格納するディレクトリを作成する。

$ sudo mkdir /etc/supervisor.d
$ sudo service supervisord start
supervisord を起動中:                                      [  OK  ]

/etc/nginx/conf.d/localhost.conf

# supervisor バックエンドの設定
upstream supervisor {
    server unix:/var/run/supervisord/supervisord.sock;
}
 
server {
    # Virtual Host の設定
    server_name localhost;
    # アクセス制限
    allow 127.0.0.1;
    deny all;
 
    # supervisor の設定
    location / {
        proxy_set_header Host $http_host;
        proxy_pass http://supervisor;
 
        allow 127.0.0.1;
        deny all;
    }
}
  • python/supervisor.1565625288.txt.gz
  • 最終更新: 2019/08/13 00:54
  • by ともやん