Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

supervisord ftw

  • Loading branch information...
commit d5a184fc0f2ca5f15aaacff63f72bc6c399cd64f 1 parent 88869db
Gleicon Moraes authored

Showing 3 changed files with 6 additions and 88 deletions. Show diff stats Hide diff stats

  1. +0 39 god.initd
  2. +6 0 uurl.conf-supervisord
  3. +0 49 uurl.god
39 god.initd
... ... @@ -1,39 +0,0 @@
1   -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/var/lib/gems/1.8/bin
2   -DAEMON=/usr/bin/god
3   -DAEMON_ARGS="-c /opt/uurl/uurl.god"
4   -NAME=uurl-god-monitor
5   -DESC=uurl-god-monitor
6   -PIDFILE=/var/run/uurl-god-monitor.pid
7   -LOGFILE=/var/log/uurl-god.log
8   -
9   -test -x $DAEMON || exit 0
10   -test -x $DAEMONBOOTSTRAP || exit 0
11   -
12   -set -e
13   -
14   -case "$1" in
15   - start)
16   - echo -n "Starting $DESC: "
17   - $DAEMON $DAEMON_ARGS -P $PIDFILE -l $LOGFILE
18   - RETVAL=$?
19   - echo "God started"
20   - ;;
21   - stop)
22   - echo -n "Stopping $DESC: "
23   - kill `cat $PIDFILE`
24   - kill `ps -e -o pid,command | grep node -m 1 | awk '{ print $1; }'`
25   - RETVAL=$?
26   - echo "God stopped"
27   - ;;
28   -
29   - restart|force-reload)
30   - ${0} stop
31   - ${0} start
32   - ;;
33   - *)
34   - echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
35   - exit 1
36   - ;;
37   -esac
38   -
39   -exit 0
6 uurl.conf-supervisord
... ... @@ -0,0 +1,6 @@
  1 +[program:uurl]
  2 +command=/usr/bin/python /opt/uurl/uurl.py
  3 +redirect_stderr=true
  4 +stdout_logfile=/var/log/uurl.log
  5 +stdout_logfile_maxbytes=10MB
  6 +
49 uurl.god
... ... @@ -1,49 +0,0 @@
1   -app_root = "/opt/uurl/"
2   -pid_root = "/var/run/"
3   -
4   -God.watch do |w|
5   - w.name = "uurl-god-instances"
6   - w.group = 'uurl-god'
7   - w.interval = 5.seconds
8   -
9   - w.start = "env python #{app_root}/uurl.py"
10   - w.stop = "kill -9 `pgrep -f uurl.py`"
11   -
12   - w.uid = ENV['USER']
13   -
14   - w.pid_file = File.join(pid_root, "uurl-monitor.pid")
15   - w.behavior(:clean_pid_file)
16   -
17   - w.start_if do |start|
18   - start.condition(:process_running) do |c|
19   - c.interval = 5.seconds
20   - c.running = false
21   - end
22   - end
23   -
24   - w.restart_if do |restart|
25   - restart.condition(:memory_usage) do |c|
26   - c.above = 100.megabytes
27   - c.times = [3, 5] # 3 out of 5 intervals
28   - end
29   -
30   - restart.condition(:cpu_usage) do |c|
31   - c.above = 50.percent
32   - c.times = 5
33   - end
34   - end
35   -
36   - # lifecycle
37   - w.lifecycle do |on|
38   - on.condition(:flapping) do |c|
39   - c.to_state = [:start, :restart]
40   - c.times = 5
41   - c.within = 5.minute
42   - c.transition = :unmonitored
43   - c.retry_in = 10.minutes
44   - c.retry_times = 5
45   - c.retry_within = 2.hours
46   - end
47   - end
48   -
49   -end

0 comments on commit d5a184f

Please sign in to comment.
Something went wrong with that request. Please try again.