class Eye::Dsl::Opts
Constants
- BOOL_OPTIONS
- INTERVAL_OPTIONS
- STR_OPTIONS
Public Class Methods
new(name = nil, parent = nil)
click to toggle source
Calls superclass method
Eye::Dsl::PureOpts::new
# File lib/eye/dsl/opts.rb, line 20 def initialize(name = nil, parent = nil) super(name, parent) @config[:application] = parent.name if parent.is_a?(Eye::Dsl::ApplicationOpts) @config[:group] = parent.name if parent.is_a?(Eye::Dsl::GroupOpts) # hack for full name @full_name = parent.full_name if @name == '__default__' && parent.respond_to?(:full_name) end
Public Instance Methods
checks(type, opts = {})
click to toggle source
# File lib/eye/dsl/opts.rb, line 30 def checks(type, opts = {}) 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
Also aliased as: check
clear_bundler_env()
click to toggle source
# File lib/eye/dsl/opts.rb, line 115 def clear_bundler_env env('GEM_PATH' => nil, 'GEM_HOME' => nil, 'RUBYOPT' => nil, 'BUNDLE_BIN_PATH' => nil, 'BUNDLE_GEMFILE' => nil) end
daemonize!()
click to toggle source
# File lib/eye/dsl/opts.rb, line 111 def daemonize! set_daemonize true end
nochecks(type)
click to toggle source
clear checks from parent
# File lib/eye/dsl/opts.rb, line 53 def nochecks(type) nac = Eye::Checker.name_and_class(type.to_sym) raise Eye::Dsl::Error, "unknown checker type #{type}" unless nac @config[:checks].try :delete, nac[:name] end
Also aliased as: nocheck
nonotify(contact)
click to toggle source
# File lib/eye/dsl/opts.rb, line 80 def nonotify(contact) @config[:notify] ||= {} @config[:notify].delete(contact.to_s) end
notify(contact, level = :warn)
click to toggle source
# File lib/eye/dsl/opts.rb, line 71 def notify(contact, level = :warn) unless Eye::Process::Notify::LEVELS[level] raise Eye::Dsl::Error, "level should be in #{Eye::Process::Notify::LEVELS.keys}" end @config[:notify] ||= {} @config[:notify][contact.to_s] = level end
notriggers(type)
click to toggle source
clear triggers from parent
# File lib/eye/dsl/opts.rb, line 60 def notriggers(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
Also aliased as: notrigger
scoped(&block)
click to toggle source
# File lib/eye/dsl/opts.rb, line 119 def scoped(&block) h = self.class.new(self.name, self) h.instance_eval(&block) Eye::Utils.deep_merge!(config, h.config, [:groups, :processes]) end
set_environment(value)
click to toggle source
# File lib/eye/dsl/opts.rb, line 85 def set_environment(value) raise Eye::Dsl::Error, "environment should be a hash, but not #{value.inspect}" unless value.is_a?(Hash) @config[:environment] ||= {} @config[:environment].merge!(value) end
set_gid(value)
click to toggle source
Calls superclass method
# File lib/eye/dsl/opts.rb, line 106 def set_gid(value) raise Eye::Dsl::Error, ':gid not supported (use ruby >= 2.0)' unless Eye::Local.supported_setsid? super end
set_stdall(value)
click to toggle source
Calls superclass method
# File lib/eye/dsl/opts.rb, line 94 def set_stdall(value) super set_stdout value set_stderr value end
set_uid(value)
click to toggle source
Calls superclass method
# File lib/eye/dsl/opts.rb, line 101 def set_uid(value) raise Eye::Dsl::Error, ':uid not supported (use ruby >= 2.0)' unless Eye::Local.supported_setsid? super end
triggers(type, opts = {})
click to toggle source
# File lib/eye/dsl/opts.rb, line 41 def triggers(type, opts = {}) 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][nac[:name]] = opts end
Also aliased as: trigger
with_server(glob = nil, &block)
click to toggle source
execute part of config on particular server array of strings regexp string
# File lib/eye/dsl/opts.rb, line 129 def with_server(glob = nil, &block) on_server = true if glob.present? host = Eye::Local.host if glob.is_a?(Array) on_server = !!glob.any?{|elem| elem == host} elsif glob.is_a?(Regexp) on_server = !!host.match(glob) elsif glob.is_a?(String) || glob.is_a?(Symbol) on_server = (host == glob.to_s) end end scoped do with_condition(on_server, &block) end on_server end