文書の過去の版を表示しています。
Supervisor - プロセス制御システム
インストール
Fedora
$ sudo dnf install supervisor
メタデータの期限切れの最終確認: 0:25:17 時間前の 2023年03月13日 06時02分01秒 に実施しました。 依存関係が解決しました。 ======================================================================================================================= パッケージ アーキテクチャー バージョン リポジトリー サイズ ======================================================================================================================= インストール: supervisor noarch 4.2.2-5.fc37 fedora 734 k トランザクションの概要 ======================================================================================================================= インストール 1 パッケージ ダウンロードサイズの合計: 734 k インストール後のサイズ: 4.0 M これでよろしいですか? [y/N]: y パッケージのダウンロード: supervisor-4.2.2-5.fc37.noarch.rpm 872 kB/s | 734 kB 00:00 ----------------------------------------------------------------------------------------------------------------------- 合計 394 kB/s | 734 kB 00:01 トランザクションの確認を実行中 トランザクションの確認に成功しました。 トランザクションのテストを実行中 トランザクションのテストに成功しました。 トランザクションを実行中 準備 : 1/1 インストール中 : supervisor-4.2.2-5.fc37.noarch 1/1 scriptletの実行中: supervisor-4.2.2-5.fc37.noarch 1/1 検証 : supervisor-4.2.2-5.fc37.noarch 1/1 インストール済み: supervisor-4.2.2-5.fc37.noarch 完了しました!
$ sudo systemctl enable --now supervisord
Created symlink /etc/systemd/system/multi-user.target.wants/supervisord.service → /usr/lib/systemd/system/supervisord.service.
$ systemctl status supervisord
● supervisord.service - Process Monitoring and Control Daemon Loaded: loaded (/usr/lib/systemd/system/supervisord.service; enabled; preset: disabled) Active: active (running) since Mon 2023-03-13 06:34:05 JST; 6s ago Process: 21987 ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf (code=exited, status=0/SUCCESS) Main PID: 21989 (supervisord) Tasks: 1 (limit: 19013) Memory: 23.5M CPU: 515ms CGroup: /system.slice/supervisord.service └─21989 /usr/bin/python3 /usr/bin/supervisord -c /etc/supervisord.conf 3月 13 06:34:04 WICKED-BEAT systemd[1]: Starting supervisord.service - Process Monitoring and Control Daemon... 3月 13 06:34:05 WICKED-BEAT systemd[1]: Started supervisord.service - Process Monitoring and Control Daemon.
pip
$ sudo pip 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
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; } }