God configuration with keepalive and interval

194 views Asked by At

I have following god configuration file.

Here I have couple of question, can you please help me:

1 - what is will w.interval and c.interval will do?

2 - I want to keep my daemon alive (w.keepalive), how can I add it in my code? One more thing here is when it calls keepalive I would like to sleep for 60 seconds or so and then start, is it possible to do?

DIR = "/home/guest/god"
God.pid_file_directory = DIR
God.watch do |w|
    w.name          =       "Test"
    w.start         =       "sh /home/guest/god/test.sh"
    w.pid_file      =       File.join(DIR, 'test.pid')
    w.behavior(:clean_pid_file)
    w.interval      =       10.seconds
    w.start_if do |start|
            start.condition(:process_running) do |c|
                    puts "Inside start condition"
                    c.interval      =       5.seconds
                    c.running       =       false
            end
    end
end
1

There are 1 answers

0
Siwei On

for the question 1, I don't know the w.interval =10.seconds, I didn't see this kind of usage in its official document. the code c.interval = 5.seconds will affect only in the scope of start_if segment.

for the question 2, see this example: ( https://github.com/mojombo/god/blob/master/test/configs/keepalive/keepalive.god )

# but unfortunately, this doesn't work for me.
God.watch do |w|
  w.name = 'keepalive'
  # ...
  w.keepalive(:interval => 60.seconds)

end