LoginSignup
6
5

More than 5 years have passed since last update.

AWSにSupervisorを導入する手順

Posted at

初期ではRoot権限が無いため、Rootのパスワードを設定

sudo su -
passwd

supervisorをインストール

sudo pip install supervisor

rootユーザーになったら以下のコマンドで設定ファイルの雛形作成

echo_supervisord_conf > /etc/supervisord.conf

プログラム毎に設定ファイル置き場を作成

sudo mkdir /etc/supervisord.d

ログ用のディレクトリを用意

sudo mkdir /var/log/supervisor/

対象プログラム毎のファイルを読み込むように設定を修正

sudo vi /etc/supervisord.conf

# 以下設定を追記
[include]
files = /etc/supervisord.d/*.conf

起動スクリプト用意

sudo vi /etc/init.d/supervisord
  • 以下内容を記載して保存
#!/bin/sh
#
# /etc/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/init.d/functions

RETVAL=0
prog="supervisord"
pidfile="/tmp/supervisord.pid"
lockfile="/var/lock/subsys/supervisord"

start()
{
echo -n $"Starting $prog: "
daemon --pidfile $pidfile /usr/local/bin/supervisord -c /etc/supervisord.conf
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch ${lockfile}
}
stop()
{
echo -n $"Shutting down $prog: "
killproc -p ${pidfile} /usr/local/bin/supervisord
RETVAL=$?
echo
if [ $RETVAL -eq 0 ] ; then
rm -f ${lockfile} ${pidfile}
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $prog
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
;;
esac

設定ファイル反映

sudo chmod +x /etc/init.d/supervisord
sudo /etc/init.d/supervisord restart

ハマったところ

  • サンプルプログラムが速攻で終わりすぎると以下のエラーが出て処理が終わるので注意
default  BACKOFF    Exited too quickly (process log may have details)
6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5