Supervisord + Amazon Linux

方法

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
[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