=====Supervisor====== デーモン化されてないアプリをデーモン化したいときに使う。daemontools的な。 ==== インストール ==== CentOS6の場合 epelが設定されてるなら # yum -y --enablerepo=epel install supervisor ====MT用のStaramanを管理したい場合==== starmanの起動用スクリプトを/var/www/tools/mt/mt.shにおいていたとして。 $ vi /var/www/tools/mt/mt.sh #!/bin/sh cd /var/www/mt STAR=/usr/local/bin/starman PID=/var/www/tools/ $STAR --l :5000 --pid $PID/mt.pid ./mt.psgi 設定ファイルは/etc/supervisor.conf \\ # vi /etc/supervisor.conf [program:mt] user=apache ; setuid to this UNIX account to run the program command=/var/www/tools/mt/mt.sh ; the program (relative uses PATH, can take args) ;priority=999 ; the relative start priority (default 999) ;autostart=true ; start at supervisord start (default: true) ;autorestart=true ; retstart at unexpected quit (default: true) redirect_stderr=true ;startsecs=10 ; number of secs prog must stay running (def. 10) ;startretries=3 ; max # of serial start failures (default 3) ;exitcodes=1 ; 'expected' exit codes for process (default 0,2) ;stopsignal=QUIT ; signal used to kill process (default TERM) ;stopwaitsecs=10 ; max num secs to wait before SIGKILL (default 10) ;log_stdout=true ; if true, log program stdout (default true) ;log_stderr=true ; if true, log program stderr (def false) stdout_logfile=/var/log/psgi/psgi.log ; child log path, use NONE for none; default AUTO logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB) ;logfile_backups=10 ; # of logfile backups (default 10) ;nodaemon=true ; (start in foreground if true;default false) ====unicornを管理したい場合==== unicornの起動用スクリプトを/var/www/tools/redmine/redmine.sh \\ $ vi /var/www/tools/redmine/redmine.sh #!/bin/sh cd /var/lib/redmine BUNDLE=/usr/local/rbenv/shims/bundle ENV=production CONF=config/unicorn_redmine.rb $BUNDLE exec unicorn_rails -E $ENV -c $CONF -p 8080 パーミッションは適宜設定。 # vi /etc/supervisor.conf [program:redmine] user=webapp command=/var/www/tools/redmine/redmine.sh redirect_stderr=true stdout_logfile=/var/log/unicorn/stdout.log logfile_maxbytes=1MB ====起動==== $ sudo /etc/init.d/supervisord start ====コマンド==== supervisorctlを使う。 $ sudo supervisorctl status # statusの確認 $ sudo supervisorctl start mt # 個別プロセスのスタート $ sudo supervisorctl stop mt # 個別プロセスのストップ