On Wed, Feb 24, 2010 at 11:59 PM, Thibauld Favre <[email protected]>wrote:
>
> We are going live next week so if cannot solve this problem soon, I'll
> have to quickly find another solution and honestly this is really
> something I'd like to avoid :/
>
I've run into this same issue and while this workaround isn't ideal, it does
provide a working solution while Alvaro and company dig deeper into the root
of the problem.
Using the god process monitor (sudo aptitude install god), the following
configuration file will monitor the memory and processor usage of cherokee
and restart it when it exceeds 50megs of memory and/or 30 percent of the
processor load. Adapt accordingly to fit your specific needs:
CHEROKEE_ROOT = '/var/cherokee'
God.watch do |w|
w.name = "cherokee"
w.interval = 5.seconds # default
w.start = "killall /usr/sbin/cherokee-worker; /etc/init.d/cherokee start"
w.stop = "/etc/init.d/cherokee stop"
w.restart = "/etc/init.d/cherokee restart"
w.pid_file = File.join(CHEROKEE_ROOT, "cherokee.pid")
# clean pid files before start if necessary
w.behavior(:clean_pid_file)
# determine the state on startup
w.transition(:init, { true => :up, false => :start }) do |on|
on.condition(:process_running) do |c|
c.running = true
end
end
# determine when process has finished starting
w.transition([:start, :restart], :up) do |on|
on.condition(:process_running) do |c|
c.running = true
end
# failsafe
on.condition(:tries) do |c|
c.times = 5
c.transition = :start
end
end
# start if process is not running
w.transition(:up, :start) do |on|
on.condition(:process_exits)
end
# restart if memory or cpu is too high
w.transition(:up, :restart) do |on|
on.condition(:memory_usage) do |c|
c.interval = 20
c.above = 50.megabytes
c.times = [3, 5]
end
on.condition(:cpu_usage) do |c|
c.interval = 10
c.above = 30.percent
c.times = [3, 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
--
/M:D
M. David Peterson
Co-Founder & Chief Architect, 3rd&Urban, LLC
Email: [email protected] | [email protected]
Mobile: (206) 999-0588
http://3rdandUrban.com | http://amp.fm |
http://www.oreillynet.com/pub/au/2354 |
http://broadcast.oreilly.com/m-david-peterson/
_______________________________________________
Cherokee mailing list
[email protected]
http://lists.octality.com/listinfo/cherokee