lib/eye/dsl/opts.rb in reel-eye-0.3.2 vs lib/eye/dsl/opts.rb in reel-eye-0.4

- old
+ new

@@ -1,16 +1,16 @@ class Eye::Dsl::Opts < Eye::Dsl::PureOpts - STR_OPTIONS = [ :pid_file, :working_dir, :stdout, :stderr, :stdall, :start_command, + STR_OPTIONS = [ :pid_file, :working_dir, :stdout, :stderr, :stdall, :start_command, :stop_command, :restart_command, :uid, :gid ] create_options_methods(STR_OPTIONS, String) - BOOL_OPTIONS = [ :daemonize, :keep_alive, :control_pid, :auto_start, :stop_on_delete] + BOOL_OPTIONS = [ :daemonize, :keep_alive, :auto_start, :stop_on_delete, :clear_pid ] create_options_methods(BOOL_OPTIONS, [TrueClass, FalseClass]) INTERVAL_OPTIONS = [ :check_alive_period, :start_timeout, :restart_timeout, :stop_timeout, :start_grace, - :restart_grace, :stop_grace, :childs_update_period ] + :restart_grace, :stop_grace, :childs_update_period, :restore_in ] create_options_methods(INTERVAL_OPTIONS, [Fixnum, Float]) create_options_methods([:environment], Hash) create_options_methods([:stop_signals], Array) create_options_methods([:umask], Fixnum) @@ -30,24 +30,24 @@ nac = Eye::Checker.name_and_class(type.to_sym) raise Eye::Dsl::Error, "unknown checker type #{type}" unless nac opts.merge!(:type => nac[:type]) Eye::Checker.validate!(opts) - + @config[:checks] ||= {} @config[:checks][nac[:name]] = opts end def triggers(type, opts = {}) - type = type.to_sym - raise Eye::Dsl::Error, "unknown trigger type #{type}" unless Eye::Trigger::TYPES[type] - - opts.merge!(:type => type) + nac = Eye::Trigger.name_and_class(type.to_sym) + raise Eye::Dsl::Error, "unknown trigger type #{type}" unless nac + + opts.merge!(:type => nac[:type]) Eye::Trigger.validate!(opts) @config[:triggers] ||= {} - @config[:triggers][type] = opts + @config[:triggers][nac[:name]] = opts end # clear checks from parent def nochecks(type) nac = Eye::Checker.name_and_class(type.to_sym) @@ -55,18 +55,23 @@ @config[:checks].try :delete, nac[:name] end # clear triggers from parent def notriggers(type) - type = type.to_sym - raise Eye::Dsl::Error, "unknown trigger type #{type}" unless Eye::Trigger::TYPES[type] - @config[:triggers].try :delete, type + nac = Eye::Trigger.name_and_class(type.to_sym) + raise Eye::Dsl::Error, "unknown trigger type #{type}" unless nac + @config[:triggers].try :delete, nac[:name] end + alias check checks + alias nocheck nochecks + alias trigger triggers + alias notrigger notriggers + def notify(contact, level = :warn) unless Eye::Process::Notify::LEVELS[level] - raise Eye::Dsl::Error, "level should be in #{Eye::Process::Notify::LEVELS.keys}" + raise Eye::Dsl::Error, "level should be in #{Eye::Process::Notify::LEVELS.keys}" end @config[:notify] ||= {} @config[:notify][contact.to_s] = level end @@ -123,10 +128,10 @@ # regexp # string def with_server(glob = nil, &block) on_server = true - if glob.present? + if glob.present? host = Eye::System.host if glob.is_a?(Array) on_server = !!glob.any?{|elem| elem == host} elsif glob.is_a?(Regexp)