文書の過去の版を表示しています。
Supervisor - プロセス制御システム
パッケージ インストール
$ sudo dnf install supervisor
自動起動設定
$ sudo systemctl enable supervisord.service
Supervisord の設定
$ 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
rc スクリプトの作成
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
supervisordの設定
設定ファイルを生成する。
$ 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
supervisordで管理するプロセスの設定
プロセス設定を格納するディレクトリを作成する。
$ sudo mkdir /etc/supervisor.d
サービスの起動
$ sudo service supervisord start supervisord を起動中: [ OK ]
Nginx の設定
/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; } }