Skip to content
Browse files

supervisord ftw

  • Loading branch information...
1 parent 88869db commit d5a184fc0f2ca5f15aaacff63f72bc6c399cd64f @gleicon committed Jan 1, 2011
Showing with 6 additions and 88 deletions.
  1. +0 −39 god.initd
  2. +6 −0 uurl.conf-supervisord
  3. +0 −49 uurl.god
View
39 god.initd
@@ -1,39 +0,0 @@
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/var/lib/gems/1.8/bin
-DAEMON=/usr/bin/god
-DAEMON_ARGS="-c /opt/uurl/uurl.god"
-NAME=uurl-god-monitor
-DESC=uurl-god-monitor
-PIDFILE=/var/run/uurl-god-monitor.pid
-LOGFILE=/var/log/uurl-god.log
-
-test -x $DAEMON || exit 0
-test -x $DAEMONBOOTSTRAP || exit 0
-
-set -e
-
-case "$1" in
- start)
- echo -n "Starting $DESC: "
- $DAEMON $DAEMON_ARGS -P $PIDFILE -l $LOGFILE
- RETVAL=$?
- echo "God started"
- ;;
- stop)
- echo -n "Stopping $DESC: "
- kill `cat $PIDFILE`
- kill `ps -e -o pid,command | grep node -m 1 | awk '{ print $1; }'`
- RETVAL=$?
- echo "God stopped"
- ;;
-
- restart|force-reload)
- ${0} stop
- ${0} start
- ;;
- *)
- echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
- exit 1
- ;;
-esac
-
-exit 0
View
6 uurl.conf-supervisord
@@ -0,0 +1,6 @@
+[program:uurl]
+command=/usr/bin/python /opt/uurl/uurl.py
+redirect_stderr=true
+stdout_logfile=/var/log/uurl.log
+stdout_logfile_maxbytes=10MB
+
View
49 uurl.god
@@ -1,49 +0,0 @@
-app_root = "/opt/uurl/"
-pid_root = "/var/run/"
-
-God.watch do |w|
- w.name = "uurl-god-instances"
- w.group = 'uurl-god'
- w.interval = 5.seconds
-
- w.start = "env python #{app_root}/uurl.py"
- w.stop = "kill -9 `pgrep -f uurl.py`"
-
- w.uid = ENV['USER']
-
- w.pid_file = File.join(pid_root, "uurl-monitor.pid")
- w.behavior(:clean_pid_file)
-
- w.start_if do |start|
- start.condition(:process_running) do |c|
- c.interval = 5.seconds
- c.running = false
- end
- end
-
- w.restart_if do |restart|
- restart.condition(:memory_usage) do |c|
- c.above = 100.megabytes
- c.times = [3, 5] # 3 out of 5 intervals
- end
-
- restart.condition(:cpu_usage) do |c|
- c.above = 50.percent
- c.times = 5
- end
- end
-
- # lifecycle
- w.lifecycle do |on|
- on.condition(:flapping) do |c|
- c.to_state = [:start, :restart]
- c.times = 5
- c.within = 5.minute
- c.transition = :unmonitored
- c.retry_in = 10.minutes
- c.retry_times = 5
- c.retry_within = 2.hours
- end
- end
-
-end

0 comments on commit d5a184f

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