Class: Eye::Dsl::Opts
Constant Summary
collapse
- STR_OPTIONS =
[ :pid_file, :working_dir, :stdout, :stderr, :stdall, :stdin, :start_command,
:stop_command, :restart_command, :uid, :gid ]
- BOOL_OPTIONS =
[ :daemonize, :keep_alive, :auto_start, :stop_on_delete, :clear_pid, :preserve_fds, :use_leaf_child, :clear_env ]
- INTERVAL_OPTIONS =
[ :check_alive_period, :start_timeout, :restart_timeout, :stop_timeout, :start_grace,
:restart_grace, :stop_grace, :children_update_period, :restore_in,
:auto_update_pidfile_grace, :revert_fuckup_pidfile_grace ]
Instance Attribute Summary
Attributes inherited from PureOpts
#config, #full_name, #name, #parent
Instance Method Summary
collapse
Methods inherited from PureOpts
#allow_options, create_options_methods, #disallow_options, #nop, #not_seed_options, #use, #with_condition
Constructor Details
#initialize(name = nil, parent = nil) ⇒ Opts
Returns a new instance of Opts.
20
21
22
23
24
25
26
27
28
|
# 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)
@full_name = parent.full_name if @name == '__default__' && parent.respond_to?(:full_name)
end
|
Instance Method Details
#checks(type, opts = {}) ⇒ Object
Also known as:
check
30
31
32
33
34
35
36
37
38
39
|
# 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
|
#clear_bundler_env ⇒ Object
115
116
117
|
# 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! ⇒ Object
111
112
113
|
# File 'lib/eye/dsl/opts.rb', line 111
def daemonize!
set_daemonize true
end
|
#nochecks(type) ⇒ Object
Also known as:
nocheck
53
54
55
56
57
|
# 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
|
#nonotify(contact) ⇒ Object
80
81
82
83
|
# File 'lib/eye/dsl/opts.rb', line 80
def nonotify(contact)
@config[:notify] ||= {}
@config[:notify].delete(contact.to_s)
end
|
#notify(contact, level = :warn) ⇒ Object
71
72
73
74
75
76
77
78
|
# 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) ⇒ Object
Also known as:
notrigger
clear triggers from parent
60
61
62
63
64
|
# 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
|
#scoped(&block) ⇒ Object
119
120
121
122
123
|
# 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) ⇒ Object
85
86
87
88
89
|
# 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_stdall(value) ⇒ Object
94
95
96
97
98
99
|
# File 'lib/eye/dsl/opts.rb', line 94
def set_stdall(value)
super
set_stdout value
set_stderr value
end
|
#triggers(type, opts = {}) ⇒ Object
Also known as:
trigger
41
42
43
44
45
46
47
48
49
50
|
# 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
|
#with_server(glob = nil, &block) ⇒ Object
execute part of config on particular server array of strings regexp string
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
# 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
|