Class: ServerEngine::MultiWorkerServer
- Inherits:
-
Server
- Object
- Server
- ServerEngine::MultiWorkerServer
show all
- Defined in:
- lib/serverengine/multi_worker_server.rb
Instance Attribute Summary
Attributes included from ConfigLoader
#config, #logger
Instance Method Summary
collapse
Methods inherited from Server
#after_run, #after_start, #before_run, #dump, #install_signal_handlers, #main
Constructor Details
#initialize(worker_module, load_config_proc = {}, &block) ⇒ MultiWorkerServer
Returns a new instance of MultiWorkerServer.
23
24
25
26
27
28
29
30
|
# File 'lib/serverengine/multi_worker_server.rb', line 23
def initialize(worker_module, load_config_proc={}, &block)
@monitors = []
@last_start_worker_time = 0
super(worker_module, load_config_proc, &block)
@stop_immediately_at_unrecoverable_exit = @config.fetch(:stop_immediately_at_unrecoverable_exit, false)
end
|
Instance Method Details
#join_workers ⇒ Object
75
76
77
78
79
|
# File 'lib/serverengine/multi_worker_server.rb', line 75
def join_workers
@monitors.each {|m|
m.join if m
}
end
|
#reload ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/serverengine/multi_worker_server.rb', line 48
def reload
super
@monitors.each_with_index do |m|
m.send_reload if m
end
nil
end
|
#restart(stop_graceful) ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/serverengine/multi_worker_server.rb', line 40
def restart(stop_graceful)
super
@monitors.each do |m|
m.send_stop(stop_graceful) if m
end
nil
end
|
#run ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/serverengine/multi_worker_server.rb', line 56
def run
while true
num_alive_or_restarting = keepalive_workers
break if num_alive_or_restarting == 0
wait_tick
end
end
|
#scale_workers(n) ⇒ Object
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/serverengine/multi_worker_server.rb', line 64
def scale_workers(n)
@num_workers = n
plus = n - @monitors.size
if plus > 0
@monitors.concat Array.new(plus, nil)
end
nil
end
|
#stop(stop_graceful) ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/serverengine/multi_worker_server.rb', line 32
def stop(stop_graceful)
super
@monitors.each do |m|
m.send_stop(stop_graceful) if m
end
nil
end
|