Created
October 3, 2009 23:26
-
-
Save entombedvirus/200977 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
state_machine :initial => :unmonitored do | |
state :unmonitored, :up, :down | |
event :tick do | |
transition :unmonitored => :unmonitored | |
transition [:up, :down] => :up, :if => :process_running? | |
transition [:up, :down] => :down, :unless => :process_running? | |
end | |
event :start do | |
transition :unmonitored => :up, :if => lambda {|process| process.process_running? || process.start_process } | |
transition :up => :up | |
transition :down => :up, :if => :start_process | |
end | |
event :stop do | |
transition [:unmonitored, :down] => :unmonitored | |
transition :up => :unmonitored, :if => :stop_process | |
end | |
event :restart do | |
transition all => :up, :if => :restart_process | |
end | |
event :unmonitor do | |
transition all => :unmonitored | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment