1 NANCY_ROOT = '/var/www/blakemizerany.com'
3 [*8000..8001].each do |port|
6 w.name = "local-#{port}"
7 w.interval = 5.seconds # default
8 w.start = "ruby #{NANCY_ROOT}/nancy.rb -p #{port} -e production"
10 # clean pid files before start if necessary
11 w.behavior(:clean_pid_file)
13 # determine the state on startup
14 w.transition(:init, { true => :up, false => :start }) do |on|
15 on.condition(:process_running) do |c|
20 # determine when process has finished starting
21 w.transition([:start, :restart], :up) do |on|
22 on.condition(:process_running) do |c|
27 on.condition(:tries) do |c|
33 # start if process is not running
34 w.transition(:up, :start) do |on|
35 on.condition(:process_exits)
38 # restart if memory or cpu is too high
39 w.transition(:up, :restart) do |on|
40 on.condition(:memory_usage) do |c|
42 c.above = 50.megabytes
46 on.condition(:cpu_usage) do |c|
55 on.condition(:flapping) do |c|
56 c.to_state = [:start, :restart]
59 c.transition = :unmonitored
60 c.retry_in = 10.minutes
62 c.retry_within = 2.hours