lib/bluepill/process.rb in bluepill-0.0.4 vs lib/bluepill/process.rb in bluepill-0.0.5

- old
+ new

@@ -18,34 +18,37 @@ attr_accessor :name, :watches, :triggers, :logger, :skip_ticks_until attr_accessor *CONFIGURABLE_ATTRIBUTES state_machine :initial => :unmonitored do - state :unmonitored, :up, :down + state :unmonitored, :up, :down, :restarting event :tick do transition :unmonitored => :unmonitored transition :up => :up, :if => :process_running? transition :up => :down, :unless => :process_running? transition :down => :up, :if => lambda {|process| process.process_running? || process.start_process } + + transition :restarting => :up, :if => :process_running? + transition :restarting => :down, :unless => :process_running? end event :start do transition :unmonitored => :up, :if => lambda {|process| process.process_running? || process.start_process } - transition :up => :up + transition [:restarting, :up] => :up transition :down => :up, :if => :start_process end event :stop do transition [:unmonitored, :down] => :unmonitored - transition :up => :unmonitored, :if => :stop_process + transition [:up, :restarting] => :unmonitored, :if => :stop_process end event :restart do - transition all => :up, :if => :restart_process + transition all => :restarting, :if => :restart_process end event :unmonitor do transition all => :unmonitored end @@ -61,11 +64,11 @@ end end def initialize(process_name, options = {}) @name = process_name - @event_mutex = Mutex.new + @event_mutex = Monitor.new @transition_history = Util::RotationalArray.new(10) @watches = [] @triggers = [] @stop_grace_time = @start_grace_time = @restart_grace_time = 3 @@ -203,9 +206,11 @@ self.clear_pid else stop_process start_process end + + true end def daemonize? !!self.daemonize end \ No newline at end of file