cesi(Centralized Supervisor Interface)をインストールした

今までpy-supervisord-monitorを利用していたが、
・認証画面がないこと
・グループ化して管理できないこと
から変更した。ポイントのみ記載する。

cesiインストール

# aptitude install sqlite3 python python-flask
# cd /usr/local/src/
# git clone https://github.com/Gamegos/cesi
# cd cesi/
# cp -R cesi /etc/
# sqlite3 /etc/cesi/userinfo.db < userinfo.sql
# vi /etc/cesi.conf
==================================
[node:node1]
username = username
password = password
host = x.x.x.x
port = 9001

[environment:production]
members = node1

[cesi]
database = /etc/cesi/userinfo.db
activity_log = /var/log/cesi-activity.log
host = 127.0.0.1
;port = 5000
;name = what name mean?
==================================
# cd /etc/cesi/
# python web.py

cesiの永続起動

supervisordに以下を追加する。

# vi /etc/supervisor/conf.d/cesi.conf
==================================
[program:cesi]
directory=/etc/cesi
command=python web.py
user=root
group=root
autostart=true
autorestart=true
redirect_stdout=true
redirect_stderr=true
stopasgroup=true
stopsignal=QUIT
stdout_logfile=/var/log/supervisor/%(program_name)s_%(process_num)s.log
stdout_logfile_maxbytes=10MB
stdout_logfile_backups=5
stderr_logfile=/var/log/supervisor/%(program_name)s_%(process_num)s_error.log
process_name=%(process_num)s
stderr_logfile_maxbytes=10MB
stderr_logfile_backups=5
==================================

cesiの80番ポート動作

nginxでリバースプロキシした。configは以下。

location / {
    try_files $uri @cesi;
}

### cesi(supervisor) ###
location @cesi {
    proxy_pass http://127.0.0.1:5000;
    include /etc/nginx/proxy_params;
}

参考URL

GitHub:gamegos/cesi
consul-template & supervisorでプロセスの可視化
nginxでURLでリバースプロキシ先を振り分ける設定

Supervisord + Amazon Linux

方法

意外と面倒臭かったためメモ

[root@ip-172-32-0-221 ec2-user]# easy_install supervisor
Searching for supervisor
Best match: supervisor 3.1.3
Processing supervisor-3.1.3-py2.6.egg
supervisor 3.1.3 is already the active version in easy-install.pth
Installing echo_supervisord_conf script to /usr/local/bin
Installing pidproxy script to /usr/local/bin
Installing supervisorctl script to /usr/local/bin
Installing supervisord script to /usr/local/bin

Using /usr/local/lib/python2.6/site-packages/supervisor-3.1.3-py2.6.egg
Processing dependencies for supervisor
Finished processing dependencies for supervisor

[root@ip-172-32-0-221 ec2-user]# /usr/local/bin/supervisord -v
3.1.3

[root@ip-172-32-0-221 ec2-user]# mkdir /etc/supervisor

[root@ip-172-32-0-221 ec2-user]# /usr/local/bin/echo_supervisord_conf > /etc/supervisor/supervisord.conf

[root@ip-172-32-0-221 ec2-user]# vi /etc/init.d/supervisord
#!/bin/sh
#
# /etc/rc.d/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

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
RETVAL=0
prog="supervisord"
pidfile="/tmp/supervisord.pid"
lockfile="/var/lock/subsys/supervisord"
configfile="/etc/supervisor/supervisord.conf"

start()
{
        echo -n $"Starting $prog: "
        daemon --pidfile $pidfile supervisord -c $configfile
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch ${lockfile}
}

stop()
{
        echo -n $"Shutting down $prog: "
        killproc -p ${pidfile} /usr/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

[root@ip-172-32-0-221 ec2-user]# chmod +x /etc/init.d/supervisord

[root@ip-172-32-0-221 ec2-user]# /etc/init.d/supervisord start
supervisord を起動中: /usr/local/lib/python2.6/site-packages/supervisor-3.1.3-py2.6.egg/supervisor/options.py:383: DeprecationWarning: Parameters to load are deprecated.  Call .resolve and .require separately.
  return pkg_resources.EntryPoint.parse("x="+spec).load(False)
                                                           [  OK  ]
[root@ip-172-32-0-221 ec2-user]# ps afx
...
26298 ?        Ss     0:00 /usr/bin/python2.6 /usr/local/bin/supervisord -c /etc/supervisor/supervisord.conf

[root@ip-172-32-0-221 ec2-user]# chkconfig --add supervisord

[root@ip-172-32-0-221 ec2-user]# chkconfig --list supervisord
supervisord     0:off   1:off   2:off   3:off   4:off   5:off   6:off

[root@ip-172-32-0-221 ec2-user]# chkconfig supervisord on

[root@ip-172-32-0-221 ec2-user]# chkconfig --list supervisord
supervisord     0:off   1:off   2:on    3:on    4:on    5:on    6:off

参考URL

Fluentd UI(公式サイト)
http://docs.fluentd.org/articles/fluentd-ui
INSTALLING SUPERVISOR ON AMAZON EC2
http://mysteryos.net/installing-supervisor-amazon-ec2/
Supervisord を Amazon Linux AMI にインストール
http://d.hatena.ne.jp/massat/20111013/1318484253