LoginSignup
19
19

More than 5 years have passed since last update.

GrowthForecast をCentOS6.5(Vagrant)に導入 Supervisor してみた、その2

Posted at

Supervisor って

適当なスクリプトをデーモン化するための便利プログラム。/etc/init.d/ 以下に起動用スクリプトを書く手間が無くていい!! あと Supervisor は、プロセス監視もしてくれるのでプロセスが死んだら自動的に再起動(設定次第ですけどね)してくれる。
※自分で管理してる(できる)サーバじゃないとこういうプログラム入れさせてくれないけどねw

適当なスクリプトをデーモン化するのにSupervisorが便利

Supervisor のインストール

easy_install からインストールできますが epel リポジトリからインストールします。epel リポジトリ の追加は、ここをみて設定するとよいです。

# yum --enablerepo=epel install -y supervisor

Supervisor 設定ファイルの編集します。/etc/supervisord.conf を開いて下記の内容を追加します。

/etc/supervisord.conf
[program:growthforecast]
command=/home/growthforecast/perl5/perlbrew/perls/perl-5.20.0/bin/perl /home/growthforecast/perl5/perlbrew/perls/perl-5.20.0/bin/growthforecast.pl --port=5125 --data-dir /var/log/growthforecast/dataprocess_name=%(program_name)s
stdout_logfile_maxbytes=1MB
stderr_logfile_maxbytes=1MB
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
user=growthforecast
autostart=true
autorestart=true

Supervisor を起動してみる

起動に失敗している場合は /var/log/supervisor/supervisord.log を見てみる。

# service supervisord start
supervisord を起動中:                                 [  OK  ]
# supervisorctl status
growthforecast RUNNING    pid 7716, uptime 0:00:07
# ps aux | grep supervisorctl 
ずらずらw

Upstart で supervisord を起動

始めから GrowthForecast を Upstart で起動すればよいのですが、supervisord も便利なので継続して使います。supervisord 自身がお亡くなりになった場合はどうしようもないので、Upstart が再始動してくれるように定義します。
ちなみに Upstart は、RHEL/CentOS 6.0 以降に導入されたデーモンツールです。

Upstart を使ってお手軽 daemon 化

/etc/init/supervisord.conf
description "supervisord"

start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec /usr/bin/supervisord -n

Upstart のコマンドで supervisord を起動します。

# service supervisord stop
# initctl start supervisord

GrowthForecast の使い方…

環境回りばかりで、GrowthForecast の使い方を失念してました汗

19
19
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
19
19