5 attr_accessor :name, :cwd, :start, :stop, :restart, :grace
8 attr_accessor :conditions
12 # no grace period by default
15 # keep track of which action each condition belongs to
18 # the list of conditions for each action
19 self.conditions = {:start => [],
35 # Instantiate a Condition of type +kind+ and pass it into the mandatory
36 # block. Attributes of the condition must be set in the config file
38 # must be in a _if block
40 puts "Watch#condition can only be called from inside a start_if block"
44 # create the condition
46 c = Condition.generate(kind)
47 rescue NoSuchConditionError => e
52 # send to block so config can set attributes
55 # call prepare on the condition
58 # exit if the Condition is invalid, the Condition will have printed
59 # out its own error messages by now
64 self.conditions[@action] << c
68 [:start, :restart].each do |cmd|
69 self.conditions[cmd].each do |c|
71 puts self.name + ' ' + c.class.name + ' [ok]'
73 puts self.name + ' ' + c.class.name + ' [fail]'
86 Dir.chdir(self.cwd) do
95 Dir.chdir(self.cwd) do
101 self.action(:stop, c)
102 self.action(:start, c)
107 Dir.chdir(self.cwd) do