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.
19
20
21
22
23
24
25
26
27
|
# File 'lib/eye/dsl/opts.rb', line 19
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
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/eye/dsl/opts.rb', line 29
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
141
142
143
|
# File 'lib/eye/dsl/opts.rb', line 141
def clear_bundler_env
env('GEM_PATH' => nil, 'GEM_HOME' => nil, 'RUBYOPT' => nil, 'BUNDLE_BIN_PATH' => nil, 'BUNDLE_GEMFILE' => nil)
end
|
#command(cmd, arg) ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/eye/dsl/opts.rb', line 70
def command(cmd, arg)
@config[:user_commands] ||= {}
if arg.is_a?(Array)
validate_signals(arg)
elsif arg.is_a?(String)
else
raise Eye::Dsl::Error, "unknown command #{cmd.inspect} type should be String or Array"
end
@config[:user_commands][cmd.to_sym] = arg
end
|
#daemonize! ⇒ Object
137
138
139
|
# File 'lib/eye/dsl/opts.rb', line 137
def daemonize!
set_daemonize true
end
|
#nochecks(type) ⇒ Object
Also known as:
nocheck
52
53
54
55
56
|
# File 'lib/eye/dsl/opts.rb', line 52
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
92
93
94
95
|
# File 'lib/eye/dsl/opts.rb', line 92
def nonotify(contact)
@config[:notify] ||= {}
@config[:notify].delete(contact.to_s)
end
|
#notify(contact, level = :warn) ⇒ Object
83
84
85
86
87
88
89
90
|
# File 'lib/eye/dsl/opts.rb', line 83
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
59
60
61
62
63
|
# File 'lib/eye/dsl/opts.rb', line 59
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
145
146
147
148
149
|
# File 'lib/eye/dsl/opts.rb', line 145
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
111
112
113
114
115
|
# File 'lib/eye/dsl/opts.rb', line 111
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
120
121
122
123
124
125
|
# File 'lib/eye/dsl/opts.rb', line 120
def set_stdall(value)
super
set_stdout value
set_stderr value
end
|
#stop_signals(*args) ⇒ Object
97
98
99
100
101
102
103
104
105
|
# File 'lib/eye/dsl/opts.rb', line 97
def stop_signals(*args)
if args.count == 0
return @config[:stop_signals]
end
signals = Array(args).flatten
validate_signals(signals)
@config[:stop_signals] = signals
end
|
#stop_signals=(s) ⇒ Object
107
108
109
|
# File 'lib/eye/dsl/opts.rb', line 107
def stop_signals=(s)
stop_signals(s)
end
|
#triggers(type, opts = {}) ⇒ Object
Also known as:
trigger
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/eye/dsl/opts.rb', line 40
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/eye/dsl/opts.rb', line 155
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
|