So, I think I got a little closer to an answer by playing with god
while watching the log.  It seems that if the app is being monitored,
the stop command works just fine:

I [2009-03-31 14:10:50]  INFO: myapp [ok] process is running
(ProcessRunning)
I [2009-03-31 14:10:55]  INFO: myapp [ok] process is running
(ProcessRunning)
I [2009-03-31 14:11:00]  INFO: myapp [ok] process is running
(ProcessRunning)

[god stop myapp here]

I [2009-03-31 14:11:02]  INFO: myapp move 'up' to 'unmonitored'
I [2009-03-31 14:11:02]  INFO: myapp moved 'up' to 'unmonitored'
I [2009-03-31 14:11:02]  INFO: myapp stop: default lambda killer
I [2009-03-31 14:11:02]  INFO: myapp sent SIGTERM
I [2009-03-31 14:11:03]  INFO: myapp process stopped

BUT, if I'm not monitoring the app (i.e., I did 'god start myapp'
without also doing 'god monitor myapp') then the app fails to stop:

I [2009-03-31 14:10:23]  INFO: myapp move 'unmonitored' to 'up'
I [2009-03-31 14:10:23]  INFO: myapp moved 'unmonitored' to 'up'
I [2009-03-31 14:10:23]  INFO: myapp [trigger] process is not running
(ProcessRunning)
I [2009-03-31 14:10:23]  INFO: myapp move 'up' to 'start'
I [2009-03-31 14:10:23]  INFO: myapp before_start: deleted pid file
(CleanPidFile)
I [2009-03-31 14:10:23]  INFO: myapp start: ruby /var/forkolator/test/
apps/valid/files/app.rb -p 20000

[god stop myapp here]

I [2009-03-31 14:10:34]  INFO: myapp moved 'up' to 'up'
I [2009-03-31 14:10:34]  INFO: myapp move 'up' to 'unmonitored'
I [2009-03-31 14:10:34]  INFO: myapp moved 'up' to 'unmonitored'

Is that expected behavior?  Seems odd that monitoring would have to be
on to stop a process.

Erik

On Mar 31, 1:32 pm, Erik Pukinskis <[email protected]> wrote:
> Hi there!
>
> First of all, god is great and greatly to be praised.  Much
> appreciation to everyone who has been working on it.
>
> I do have a problem, however.  I spent all day yesterday struggling
> with getting god to reliably start and stop a sinatra app.  I've
> gotten god files that can stop a sinatra app *sometimes*, when I hit
> god a bunch of times with successive monitor/stop commands, which
> leads me to believe there's some kind of race condition happening, but
> who knows.
>
> Anyway, below are my .god file and my sinatra app, which are as
> barebones as I could get them.  The app starts, but when you ask it to
> stop, it just keeps chugging along! It works to do:
>
> god unmonitor myapp;kill `cat /var/run/god/myapp.pid`
>
> But that sort of defeats the purpose of god!
>
> Anyway, if anyone can unravel this mystery for me, you will relieve a
> very large knot from my shoulders and make me feel a lot better about
> how I spent my yesterday.
>
> With love,
> Erik
>
> # config.god:
>
> God.watch do |w|
>   w.name = "myapp"
>   w.interval = 30.seconds # default
>   w.start = "ruby /path/to/app.rb -p 20000"
>   w.start_grace = 10.seconds
>   w.restart_grace = 10.seconds
>
>   w.behavior(:clean_pid_file)
>
>   # Checks if process is running every 5 seconds
>   w.start_if do |start|
>     start.condition(:process_running) do |c|
>       c.interval = 5.seconds
>       c.running = false
>     end
>   end
> end
>
> # app.rb:
>
> require 'rubygems'
> require 'sinatra'
>
> set :port, ARGV[1] if ARGV[0] == "-p"
>
> get '/' do
>   "Hello World!"
> end
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"god.rb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/god-rb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to