Skip to content

Instantly share code, notes, and snippets.

@octplane
Created October 14, 2011 13:15
Show Gist options
  • Select an option

  • Save octplane/1287060 to your computer and use it in GitHub Desktop.

Select an option

Save octplane/1287060 to your computer and use it in GitHub Desktop.
Simple sumr wrapper
def should_i_start?
puts "Should I ?"
Time.now.min % 2 == 1
end
def setup_watch(w)
w.stop_if do |on|
on.condition(:lambda) do |lam|
lam.interval = 5.seconds
lam.lambda = lambda { ! should_i_start? }
end
end
w.restart_if do |on|
on.condition(:lambda) do |lam|
lam.interval = 5.seconds
lam.lambda = lambda { should_i_start? }
end
end
end
God.watch do |w|
w.name = "sumr"
w.group = 'seasons'
w.interval = 5.seconds
w.dir = "/tmp/"
w.start = "ruby /tmp/dru"
w.log = "/tmp/dru.log"
setup_watch(w)
end
@octplane
Copy link
Author

I'd expect this god configuration file to start my daemon and stop it every other minute. Unfortunately, after the first stop event, it never starts again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment