Class: Sensu::API::Process
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Sensu::API::Process
show all
- Extended by:
- Daemon
- Defined in:
- lib/sensu/api/process.rb
Class Method Summary
collapse
Methods included from Daemon
initialize, load_extensions, load_settings, log_concerns, pause, resume, setup_logger, setup_process, setup_redis, setup_signal_traps, setup_transport, start, stop
Methods included from Utilities
#deep_merge, #random_uuid, #redact_sensitive, #retry_until_true, #testing?
Class Method Details
.bootstrap(options) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/sensu/api/process.rb', line 39
def bootstrap(options)
setup_logger(options)
set :logger, @logger
load_settings(options)
set :api, @settings[:api]
set :checks, @settings[:checks]
set :all_checks, @settings.checks
set :cors, @settings[:cors] || {
"Origin" => "*",
"Methods" => "GET, POST, PUT, DELETE, OPTIONS",
"Credentials" => "true",
"Headers" => "Origin, X-Requested-With, Content-Type, Accept, Authorization"
}
on_reactor_run
self
end
|
.on_reactor_run ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/sensu/api/process.rb', line 30
def on_reactor_run
EM::next_tick do
setup_redis
set :redis, @redis
setup_transport
set :transport, @transport
end
end
|
.run(options = {}) ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/sensu/api/process.rb', line 21
def run(options={})
bootstrap(options)
setup_process(options)
EM::run do
start
setup_signal_traps
end
end
|
.start ⇒ Object
73
74
75
76
|
# File 'lib/sensu/api/process.rb', line 73
def start
start_server
super
end
|
.start_server ⇒ Object
56
57
58
59
60
61
|
# File 'lib/sensu/api/process.rb', line 56
def start_server
Thin::Logging.silent = true
bind = @settings[:api][:bind] || "0.0.0.0"
@thin = Thin::Server.new(bind, @settings[:api][:port], self)
@thin.start
end
|
.stop ⇒ Object
78
79
80
81
82
83
84
85
|
# File 'lib/sensu/api/process.rb', line 78
def stop
@logger.warn("stopping")
stop_server do
@redis.close
@transport.close
super
end
end
|
.stop_server(&callback) ⇒ Object
63
64
65
66
67
68
69
70
71
|
# File 'lib/sensu/api/process.rb', line 63
def stop_server(&callback)
@thin.stop
retry_until_true do
unless @thin.running?
callback.call
true
end
end
end
|
.test(options = {}) ⇒ Object
87
88
89
90
|
# File 'lib/sensu/api/process.rb', line 87
def test(options={})
bootstrap(options)
start
end
|