jstorimer-deep-test 0.2.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. data/.gitignore +0 -1
  2. data/README.rdoc +70 -41
  3. data/Rakefile +104 -32
  4. data/TODO +2 -2
  5. data/VERSION +1 -1
  6. data/bin/deep_test +15 -0
  7. data/jstorimer-deep-test-0.1.0.gem +0 -0
  8. data/jstorimer-deep-test.gemspec +1425 -0
  9. data/lib/deep_test.rb +40 -28
  10. data/lib/deep_test/database/mysql_setup_listener.rb +12 -12
  11. data/lib/deep_test/database/setup_listener.rb +23 -23
  12. data/lib/deep_test/distributed/dispatch_controller.rb +10 -17
  13. data/lib/deep_test/distributed/drb_client_connection_info.rb +15 -0
  14. data/lib/deep_test/distributed/master_test_server.rb +52 -0
  15. data/lib/deep_test/distributed/multi_test_server_proxy.rb +44 -0
  16. data/lib/deep_test/distributed/null_work_unit.rb +12 -0
  17. data/lib/deep_test/distributed/remote_worker_client.rb +54 -0
  18. data/lib/deep_test/distributed/remote_worker_server.rb +82 -0
  19. data/lib/deep_test/distributed/rsync.rb +12 -25
  20. data/lib/deep_test/distributed/show_status.rhtml +41 -0
  21. data/lib/deep_test/distributed/test_server.rb +78 -0
  22. data/lib/deep_test/distributed/test_server_status.rb +9 -0
  23. data/lib/deep_test/distributed/test_server_workers.rb +24 -0
  24. data/lib/deep_test/distributed/throughput_runner.rb +42 -0
  25. data/lib/deep_test/distributed/throughput_statistics.rb +26 -0
  26. data/lib/deep_test/distributed/throughput_worker_client.rb +19 -0
  27. data/lib/deep_test/extensions/drb_extension.rb +34 -0
  28. data/lib/deep_test/listener_list.rb +1 -1
  29. data/lib/deep_test/local_workers.rb +55 -0
  30. data/lib/deep_test/logger.rb +2 -17
  31. data/lib/deep_test/marshallable_exception_wrapper.rb +4 -4
  32. data/lib/deep_test/metrics/gatherer.rb +67 -0
  33. data/lib/deep_test/metrics/queue_lock_wait_time_measurement.rb +133 -0
  34. data/lib/deep_test/{null_listener.rb → null_worker_listener.rb} +14 -14
  35. data/lib/deep_test/option.rb +60 -0
  36. data/lib/deep_test/options.rb +42 -45
  37. data/lib/deep_test/process_orchestrator.rb +49 -0
  38. data/lib/deep_test/rake_tasks.rb +1 -3
  39. data/lib/deep_test/result_reader.rb +6 -10
  40. data/lib/deep_test/rspec_detector.rb +1 -1
  41. data/lib/deep_test/server.rb +75 -0
  42. data/lib/deep_test/spec.rb +1 -5
  43. data/lib/deep_test/spec/extensions/example_methods.rb +1 -7
  44. data/lib/deep_test/spec/extensions/reporter.rb +29 -0
  45. data/lib/deep_test/spec/extensions/spec_task.rb +2 -3
  46. data/lib/deep_test/spec/runner.rb +17 -32
  47. data/lib/deep_test/spec/work_result.rb +0 -2
  48. data/lib/deep_test/test/runner.rb +2 -2
  49. data/lib/deep_test/test/supervised_test_suite.rb +10 -9
  50. data/lib/deep_test/test/work_result.rb +0 -1
  51. data/lib/deep_test/test_task.rb +1 -1
  52. data/lib/deep_test/ui/console.rb +11 -9
  53. data/lib/deep_test/warlock.rb +25 -37
  54. data/lib/deep_test/worker.rb +57 -0
  55. data/sample_rails_project/deep_test.rb +0 -4
  56. data/sample_rails_project/lib/{foreign_host_agent_simulation_listener.rb → foreign_host_worker_simulation_listener.rb} +4 -6
  57. data/sample_rails_project/lib/tasks/deep_test.rake +4 -13
  58. data/script/internal/run_test_suite.rb +7 -0
  59. data/script/public/master_test_server.rb +24 -0
  60. data/script/public/test_server.rb +18 -0
  61. data/script/public/test_throughput.rb +29 -0
  62. data/spec/deep_test/option_spec.rb +33 -0
  63. data/spec/deep_test/options_spec.rb +59 -80
  64. data/spec/deep_test/spec/extensions/example_methods_spec.rb +4 -5
  65. data/spec/deep_test/spec/extensions/spec_task_spec.rb +6 -4
  66. data/spec/deep_test/spec/runner_spec.rb +32 -59
  67. data/spec/spec_helper.rb +6 -14
  68. data/spec/thread_worker.rb +25 -0
  69. data/test/deep_test/database/mysql_setup_listener_test.rb +9 -13
  70. data/test/deep_test/distributed/dispatch_controller_test.rb +177 -130
  71. data/test/deep_test/distributed/drb_client_connection_info_test.rb +42 -0
  72. data/test/deep_test/distributed/filename_resolver_test.rb +34 -38
  73. data/test/deep_test/distributed/master_test_server_test.rb +32 -0
  74. data/test/deep_test/distributed/multi_test_server_proxy_test.rb +96 -0
  75. data/test/deep_test/distributed/remote_worker_client_test.rb +180 -0
  76. data/test/deep_test/distributed/remote_worker_server_test.rb +99 -0
  77. data/test/deep_test/distributed/rsync_test.rb +62 -42
  78. data/test/deep_test/distributed/test_server_test.rb +94 -0
  79. data/test/deep_test/distributed/test_server_workers_test.rb +26 -0
  80. data/test/deep_test/distributed/throughput_runner_test.rb +68 -0
  81. data/test/deep_test/distributed/throughput_worker_client_test.rb +28 -0
  82. data/test/deep_test/listener_list_test.rb +15 -17
  83. data/test/deep_test/local_workers_test.rb +22 -0
  84. data/test/deep_test/logger_test.rb +7 -34
  85. data/test/deep_test/marshallable_exception_wrapper_test.rb +29 -31
  86. data/test/deep_test/metrics/gatherer_test.rb +66 -0
  87. data/test/deep_test/process_orchestrator_test.rb +11 -0
  88. data/test/deep_test/result_reader_test.rb +95 -95
  89. data/test/deep_test/server_test.rb +58 -0
  90. data/test/deep_test/test/extensions/error_test.rb +36 -38
  91. data/test/deep_test/test/runner_test.rb +3 -7
  92. data/test/deep_test/test/supervised_test_suite_test.rb +61 -89
  93. data/test/deep_test/test/work_result_test.rb +76 -80
  94. data/test/deep_test/test/work_unit_test.rb +51 -53
  95. data/test/deep_test/test_task_test.rb +38 -10
  96. data/test/deep_test/ui/console_test.rb +4 -8
  97. data/test/deep_test/warlock_test.rb +31 -33
  98. data/test/deep_test/worker_test.rb +94 -0
  99. data/test/failing.rake +11 -0
  100. data/{negative_acceptance_tests/failing_test.rb → test/failing.rb} +1 -3
  101. data/{infrastructure → test}/fake_deadlock_error.rb +0 -0
  102. data/test/simple_test_blackboard.rb +45 -0
  103. data/test/simple_test_blackboard_test.rb +33 -0
  104. data/{infrastructure → test}/test_factory.rb +0 -0
  105. data/test/test_helper.rb +5 -20
  106. data/test/test_task_test.rb +57 -60
  107. metadata +78 -87
  108. data/infrastructure/dynamic_teardown.rb +0 -22
  109. data/infrastructure/load.rb +0 -11
  110. data/infrastructure/test_central_command.rb +0 -15
  111. data/infrastructure/test_exception.rb +0 -7
  112. data/infrastructure/test_logger.rb +0 -11
  113. data/infrastructure/test_operator.rb +0 -15
  114. data/infrastructure/test_result.rb +0 -15
  115. data/infrastructure/thread_agent.rb +0 -21
  116. data/infrastructure/timewarp/Rakefile +0 -14
  117. data/infrastructure/timewarp/lib/timewarp.rb +0 -21
  118. data/infrastructure/timewarp/test/timewarp_test.rb +0 -45
  119. data/lib/deep_test/agent.rb +0 -108
  120. data/lib/deep_test/central_command.rb +0 -165
  121. data/lib/deep_test/cpu_info.rb +0 -22
  122. data/lib/deep_test/demon.rb +0 -25
  123. data/lib/deep_test/distributed/beachhead.rb +0 -104
  124. data/lib/deep_test/distributed/establish_beachhead.rb +0 -19
  125. data/lib/deep_test/distributed/landing_fleet.rb +0 -30
  126. data/lib/deep_test/distributed/landing_ship.rb +0 -60
  127. data/lib/deep_test/distributed/remote_deployment.rb +0 -56
  128. data/lib/deep_test/distributed/shell_environment.rb +0 -50
  129. data/lib/deep_test/distributed/ssh_client_connection_info.rb +0 -14
  130. data/lib/deep_test/failure_message.rb +0 -19
  131. data/lib/deep_test/lib_root.rb +0 -4
  132. data/lib/deep_test/local_deployment.rb +0 -46
  133. data/lib/deep_test/main.rb +0 -41
  134. data/lib/deep_test/metrics/data.rb +0 -34
  135. data/lib/deep_test/metrics/measurement.rb +0 -39
  136. data/lib/deep_test/proxy_io.rb +0 -77
  137. data/lib/deep_test/test/run_test_suite.rb +0 -5
  138. data/lib/telegraph.rb +0 -29
  139. data/lib/telegraph/ack_sequence.rb +0 -14
  140. data/lib/telegraph/logging.rb +0 -20
  141. data/lib/telegraph/message.rb +0 -39
  142. data/lib/telegraph/operator.rb +0 -47
  143. data/lib/telegraph/switchboard.rb +0 -57
  144. data/lib/telegraph/wire.rb +0 -73
  145. data/negative_acceptance_tests/dying_spec.rb +0 -13
  146. data/negative_acceptance_tests/dying_test.rb +0 -13
  147. data/negative_acceptance_tests/failing_spec.rb +0 -9
  148. data/negative_acceptance_tests/kill_agent_one_on_start_work.rb +0 -16
  149. data/negative_acceptance_tests/passing_spec.rb +0 -10
  150. data/negative_acceptance_tests/passing_test.rb +0 -12
  151. data/negative_acceptance_tests/tasks.rake +0 -87
  152. data/negative_acceptance_tests/tests.rb +0 -60
  153. data/test/deep_test/agent_test.rb +0 -175
  154. data/test/deep_test/central_command_test.rb +0 -147
  155. data/test/deep_test/cpu_info_test.rb +0 -33
  156. data/test/deep_test/demon_test.rb +0 -23
  157. data/test/deep_test/distributed/beachhead_test.rb +0 -67
  158. data/test/deep_test/distributed/landing_fleet_test.rb +0 -55
  159. data/test/deep_test/distributed/landing_ship_test.rb +0 -48
  160. data/test/deep_test/distributed/remote_deployment_test.rb +0 -134
  161. data/test/deep_test/distributed/shell_environment_fixtures/set_bar_to_foo +0 -1
  162. data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_bar +0 -1
  163. data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_baz +0 -1
  164. data/test/deep_test/distributed/shell_environment_test.rb +0 -108
  165. data/test/deep_test/distributed/ssh_client_connection_info_test.rb +0 -34
  166. data/test/deep_test/local_deployment_test.rb +0 -19
  167. data/test/deep_test/main_test.rb +0 -12
  168. data/test/deep_test/metrics/data_test.rb +0 -22
  169. data/test/deep_test/metrics/measurement_test.rb +0 -18
  170. data/test/deep_test/proxy_io_test.rb +0 -104
@@ -1,45 +0,0 @@
1
- $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
2
- require 'test/unit'
3
- require 'timewarp'
4
- require 'rubygems'
5
- require 'shoulda'
6
-
7
- class TimewarpTest < Test::Unit::TestCase
8
- context "control_timeline" do
9
- should "yield" do
10
- assert_equal :foo, Timewarp.control_timeline(proc {}) {:foo}
11
- end
12
-
13
- should "repeatedly call supplied proc every time Time.now is called" do
14
- time_values = [:timepoint_1, :timepoint_2]
15
- Timewarp.control_timeline(proc {time_values.shift}) do
16
- assert_equal :timepoint_1, Time.now
17
- assert_equal :timepoint_2, Time.now
18
- assert_equal nil, Time.now
19
- end
20
- end
21
-
22
- should "restorte the normal flow of time even if exception occurs" do
23
- Timewarp.control_timeline(proc {}) {raise "error"} rescue nil
24
- time_1 = Time.now
25
- sleep 0.01
26
- time_2 = Time.now
27
-
28
- assert time_1 < time_2
29
- end
30
- end
31
-
32
- context "freeze" do
33
- should "yield" do
34
- assert_equal :foo, Timewarp.freeze(:frozen_time) {:foo}
35
- end
36
-
37
- should "return a constant time" do
38
- assert_equal :frozen_time, Timewarp.freeze(:frozen_time) {Time.now}
39
- end
40
-
41
- should "parse the time if it is a string" do
42
- assert_equal Time.parse("2009-07-01 12:01:01"), Timewarp.freeze("2009-07-01 12:01:01") {Time.now}
43
- end
44
- end
45
- end
@@ -1,108 +0,0 @@
1
- module DeepTest
2
- class Agent
3
- include Demon
4
- attr_reader :number
5
-
6
- def initialize(number, options, listener)
7
- @number = number
8
- @listener = listener
9
- @options = options
10
- end
11
-
12
- def connect(stream_to_parent_process)
13
- DeepTest.logger.debug { "Agent: Connecting to #{@options.origin_hostname}:#{@options.server_port}" }
14
- @options.connect_to_central_command do |wire|
15
- stream_to_parent_process.puts "Connected"
16
- stream_to_parent_process.close rescue nil
17
- yield wire
18
- end
19
- ensure
20
- stream_to_parent_process.close unless stream_to_parent_process.closed?
21
- end
22
-
23
- def execute(stream_from_child_process, stream_to_parent_process)
24
- stream_from_child_process.close
25
- connect(stream_to_parent_process) do |wire|
26
- reseed_random_numbers
27
- reconnect_to_database
28
-
29
- @listener.starting(self)
30
- wire.send_message CentralCommand::NeedWork
31
-
32
- while work_unit_message = next_work_unit_message(wire)
33
- @listener.starting_work(self, work_unit_message.body)
34
-
35
- result = begin
36
- Metrics::Measurement.send_home("Agents Performing Work", wire, @options) do
37
- work_unit_message.body.run
38
- end
39
- rescue Exception => error
40
- Error.new(work_unit_message.body, error)
41
- end
42
-
43
- @listener.finished_work(self, work_unit_message.body, result)
44
- send_result wire, work_unit_message, result
45
- end
46
- end
47
- rescue CentralCommand::NoWorkUnitsRemainingError
48
- DeepTest.logger.debug { "Agent #{number}: no more work to do" }
49
- end
50
-
51
- def next_work_unit_message(wire)
52
- Metrics::Measurement.send_home("Agents Retrieving Work", wire, @options) do
53
- begin
54
- message = wire.next_message(:timeout => 2)
55
- next message.body == CentralCommand::NoMoreWork ? nil : message
56
- rescue Telegraph::NoMessageAvailable
57
- DeepTest.logger.debug { "Agent: NoMessageAvailable" }
58
- retry
59
- rescue Telegraph::LineDead
60
- DeepTest.logger.debug { "Agent: LineDead" }
61
- next nil
62
- end
63
- end
64
- end
65
-
66
- def send_result(wire, work_unit_message, result)
67
- wire.send_message result, :ack => work_unit_message
68
- end
69
-
70
- def reconnect_to_database
71
- ActiveRecord::Base.connection.reconnect! if defined?(ActiveRecord::Base)
72
- end
73
-
74
- def reseed_random_numbers
75
- srand
76
- end
77
-
78
-
79
- class Error
80
- include CentralCommand::Result
81
-
82
- attr_accessor :work_unit, :error
83
-
84
- def initialize(work_unit, error)
85
- @work_unit, @error = work_unit, error
86
- end
87
-
88
- def _dump(limit)
89
- Marshal.dump([@work_unit, @error], limit)
90
- rescue
91
- Marshal.dump(["<< Undumpable >>", @error], limit)
92
- end
93
-
94
- def self._load(string)
95
- new *Marshal.load(string)
96
- end
97
-
98
- def ==(other)
99
- work_unit == other.work_unit &&
100
- error == other.error
101
- end
102
-
103
- def to_s
104
- "#{@work_unit}: #{@error}\n" + (@error.backtrace || []).join("\n")
105
- end
106
- end
107
- end
108
- end
@@ -1,165 +0,0 @@
1
- require 'set'
2
-
3
- module DeepTest
4
- class CentralCommand
5
- attr_reader :operator
6
- attr_reader :switchboard
7
- attr_reader :data
8
-
9
- def initialize(options)
10
- @options = options
11
- @work_queue = Queue.new
12
- @results_mutex = Mutex.new
13
- @results_condvar = ConditionVariable.new
14
- @results = []
15
- @data = Metrics::Data.new
16
- end
17
-
18
- def done_with_work
19
- @done_with_work = true
20
- end
21
-
22
- def take_result
23
- @results_mutex.synchronize do
24
- loop do
25
- if @results.any?
26
- return @results.shift
27
- else
28
- @results_condvar.wait @results_mutex
29
- raise NoAgentsRunningError unless @results.any? || @switchboard.any_live_wires?
30
- end
31
- end
32
- end
33
- end
34
-
35
- def take_work
36
- @work_queue.pop(true)
37
- rescue ThreadError => e
38
- if e.message == "queue empty"
39
- raise NoWorkUnitsRemainingError if @done_with_work
40
- raise NoWorkUnitsAvailableError
41
- else
42
- raise
43
- end
44
- end
45
-
46
- def write_result(result)
47
- @results_mutex.synchronize do
48
- @results << result
49
- @results_condvar.signal
50
- end
51
- end
52
-
53
- def write_work(work_unit)
54
- @work_queue.push work_unit
55
- end
56
-
57
- def stdout
58
- $stdout
59
- end
60
-
61
- def stderr
62
- $stderr
63
- end
64
-
65
- def self.start(options)
66
- central_command = new(options)
67
- central_command.start
68
- central_command
69
- end
70
-
71
- def start
72
- @switchboard = Telegraph::Switchboard.new
73
- @operator = Telegraph::Operator.listen("0.0.0.0", 0, @switchboard)
74
- @options.server_port = @operator.port
75
- @process_messages_thread = Thread.new { process_messages }
76
-
77
- DeepTest.logger.info { "Started DeepTest service on port #{@operator.port}" }
78
- end
79
-
80
- unless defined?(NeedWork)
81
- NeedWork = "NeedWork"
82
- NoMoreWork = "NoMoreWork"
83
- module Result; end
84
- module Operation; end
85
- end
86
-
87
- def process_messages
88
- loop do
89
- begin
90
- return if @stop_process_messages
91
- wires_waiting_for_work.each { |w| send_work w }
92
-
93
- @results_mutex.synchronize do
94
- # make take_result wake up and check if any agents are running
95
- @results_condvar.signal
96
- end
97
-
98
- message, wire = switchboard.next_message(:timeout => 0.5)
99
-
100
- case message.body
101
- when NeedWork
102
- send_work wire
103
- when Result
104
- write_result message.body
105
- send_work wire
106
- when Operation
107
- message.body.execute
108
- when Metrics::Measurement
109
- data.add message.body
110
- else
111
- raise UnexpectedMessageError, message.inspect
112
- end
113
-
114
- rescue Telegraph::NoMessageAvailable
115
- retry
116
- rescue Exception => e
117
- raise unless @stop_process_messages
118
- end
119
- end
120
- end
121
-
122
- def wires_waiting_for_work
123
- @wires_waiting_for_work ||= Set.new
124
- end
125
-
126
- def send_work(wire)
127
- begin
128
- wire.send_message take_work, :need_ack => true
129
- wires_waiting_for_work.delete wire
130
-
131
- rescue NoWorkUnitsAvailableError
132
- put_abandonded_work_back_on_the_queue
133
- wires_waiting_for_work.add wire
134
-
135
- rescue NoWorkUnitsRemainingError
136
- wire.send_message NoMoreWork
137
- wires_waiting_for_work.delete wire
138
-
139
- end
140
- end
141
-
142
- def put_abandonded_work_back_on_the_queue
143
- closed_wires = switchboard.using_wires { |wires| wires.select {|w| w.closed? }}
144
- closed_wires.each do |wire|
145
- wire.unacked_messages.each do |m|
146
- write_work m.body
147
- switchboard.drop_wire wire
148
- end
149
- end
150
- end
151
-
152
- def stop
153
- @stop_process_messages = true
154
- operator.shutdown
155
- @process_messages_thread.join
156
- data.save @options.metrics_file if @options.gathering_metrics?
157
- end
158
-
159
- class NoWorkUnitsAvailableError < StandardError; end
160
- class NoWorkUnitsRemainingError < StandardError; end
161
- class NoAgentsRunningError < StandardError; end
162
- class CheckIfAgentsAreStillRunning < StandardError; end
163
- class UnexpectedMessageError < StandardError; end
164
- end
165
- end
@@ -1,22 +0,0 @@
1
- module DeepTest
2
- class CpuInfo
3
- attr_accessor :platform
4
-
5
- def initialize(platform = RUBY_PLATFORM)
6
- @platform = platform
7
- end
8
-
9
- def count
10
- case platform
11
- when /darwin/
12
- output = `sysctl -n hw.ncpu`
13
- output.strip.to_i
14
- when /linux/
15
- File.readlines("/proc/cpuinfo").inject(0) do |count, line|
16
- next count + 1 if line =~ /processor\s*:\s*\d+/
17
- count
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,25 +0,0 @@
1
- module DeepTest
2
- module Demon
3
- def forked(name, options, demon_args)
4
- options.connect_to_central_command do |wire|
5
- ProxyIO.replace_stdout_stderr!(wire) do
6
- begin
7
- catch(:exit_demon) do
8
- Signal.trap("TERM") { throw :exit_demon }
9
- execute *demon_args
10
- end
11
- rescue SystemExit => e
12
- raise
13
- rescue Exception => e
14
- FailureMessage.show self.class.name, "Process #{Process.pid} exiting with excetion: #{e.class}: #{e.message}"
15
- raise
16
- end
17
- end
18
- end
19
- end
20
-
21
- def execute(*args)
22
- raise "#{self.class} must implement the execute method to be a Demon"
23
- end
24
- end
25
- end
@@ -1,104 +0,0 @@
1
- module DeepTest
2
- module Distributed
3
- class Beachhead < LocalDeployment
4
- include Demon
5
-
6
- MERCY_KILLING_GRACE_PERIOD = 10 * 60 unless defined?(MERCY_KILLING_GRACE_PERIOD)
7
-
8
- def initialize(base_path, options)
9
- super options
10
- @base_path = base_path
11
- end
12
-
13
- def launch_mercy_killer(grace_period)
14
- Thread.new do
15
- sleep grace_period
16
- exit(0) unless agents_deployed?
17
- end
18
- end
19
-
20
- def load_files(files)
21
- spec_support_path = File.expand_path(File.dirname(__FILE__) + "/../spec")
22
- Dir.chdir @base_path
23
- resolver = FilenameResolver.new(@base_path)
24
- files.each do |file|
25
- load resolver.resolve(file)
26
- end
27
-
28
- # Load rspec support if rspec is available now that we've loaded the host project files
29
- #
30
- DeepTest::RSpecDetector.if_rspec_available do
31
- require spec_support_path
32
- end
33
- end
34
-
35
- def deploy_agents
36
- @agents_deployed = true
37
- super
38
- warlock.exit_when_none_running
39
- end
40
-
41
- def agents_deployed?
42
- @agents_deployed
43
- end
44
-
45
- def forked(*args)
46
- $stdout.reopen("/dev/null")
47
- $stderr.reopen("/dev/null")
48
- super
49
- end
50
-
51
- def execute(innie, outie, grace_period)
52
- innie.close
53
-
54
- switchboard = Telegraph::Switchboard.new
55
- operator = Telegraph::Operator.listen "0.0.0.0", 0, switchboard
56
-
57
- DeepTest.logger.debug { "Beachhead started on port #{operator.port}" }
58
-
59
- outie.write operator.port
60
- outie.close
61
-
62
- launch_mercy_killer grace_period
63
-
64
- loop do
65
- begin
66
- switchboard.process_messages :timeout => 1 do |message, wire|
67
- case message.body
68
- when LoadFiles
69
- load_files message.body.files
70
- when DeployAgents
71
- deploy_agents
72
- wire.send_message Done
73
- operator.shutdown
74
- break
75
- end
76
- end
77
- end
78
- end
79
- end
80
-
81
- def daemonize(grace_period = MERCY_KILLING_GRACE_PERIOD)
82
- innie, outie = IO.pipe
83
-
84
- warlock.start "Beachhead", self, innie, outie, grace_period
85
-
86
- outie.close
87
- port = innie.gets
88
- innie.close
89
- port.to_i
90
- end
91
-
92
- unless defined? DeployAgents
93
- DeployAgents = "DeployAgents"
94
- Done = "Done"
95
- class LoadFiles
96
- attr_reader :files
97
- def initialize(files)
98
- @files = files
99
- end
100
- end
101
- end
102
- end
103
- end
104
- end