Class: DeepTest::Distributed::RemoteWorkerServer
- Inherits:
-
Object
- Object
- DeepTest::Distributed::RemoteWorkerServer
- Includes:
- DRb::DRbUndumped
- Defined in:
- lib/deep_test/distributed/remote_worker_server.rb
Constant Summary collapse
- MERCY_KILLING_GRACE_PERIOD =
10 * 60
Class Method Summary collapse
- .running_server_count ⇒ Object
- .start(address, base_path, workers, grace_period = MERCY_KILLING_GRACE_PERIOD) ⇒ Object
- .stop_all ⇒ Object
- .warlock ⇒ Object
Instance Method Summary collapse
-
#initialize(base_path, workers) ⇒ RemoteWorkerServer
constructor
A new instance of RemoteWorkerServer.
- #launch_mercy_killer(grace_period) ⇒ Object
- #load_files(files) ⇒ Object
- #start_all ⇒ Object
- #stop_all ⇒ Object
- #workers_started? ⇒ Boolean
Constructor Details
#initialize(base_path, workers) ⇒ RemoteWorkerServer
Returns a new instance of RemoteWorkerServer.
8 9 10 11 |
# File 'lib/deep_test/distributed/remote_worker_server.rb', line 8 def initialize(base_path, workers) @base_path = base_path @workers = workers end |
Class Method Details
.running_server_count ⇒ Object
47 48 49 |
# File 'lib/deep_test/distributed/remote_worker_server.rb', line 47 def self.running_server_count @warlock.demon_count if @warlock end |
.start(address, base_path, workers, grace_period = MERCY_KILLING_GRACE_PERIOD) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/deep_test/distributed/remote_worker_server.rb', line 55 def self.start(address, base_path, workers, grace_period = MERCY_KILLING_GRACE_PERIOD) innie, outie = IO.pipe warlock.start("RemoteWorkerServer") do innie.close server = new(base_path, workers) DRb.start_service("drubyall://#{address}:0", server) DeepTest.logger.info "RemoteWorkerServer started at #{DRb.uri}" outie.write DRb.uri outie.close server.launch_mercy_killer(grace_period) DRb.thread.join end outie.close uri = innie.gets innie.close DRbObject.new_with_uri(uri) end |
.stop_all ⇒ Object
51 52 53 |
# File 'lib/deep_test/distributed/remote_worker_server.rb', line 51 def self.stop_all @warlock.stop_all if @warlock end |
Instance Method Details
#launch_mercy_killer(grace_period) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/deep_test/distributed/remote_worker_server.rb', line 13 def launch_mercy_killer(grace_period) Thread.new do sleep grace_period exit(0) unless workers_started? end end |
#load_files(files) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/deep_test/distributed/remote_worker_server.rb', line 20 def load_files(files) Dir.chdir @base_path resolver = FilenameResolver.new(@base_path) files.each do |file| load resolver.resolve(file) end end |
#start_all ⇒ Object
28 29 30 31 |
# File 'lib/deep_test/distributed/remote_worker_server.rb', line 28 def start_all @workers_started = true @workers.start_all end |
#stop_all ⇒ Object
33 34 35 36 37 |
# File 'lib/deep_test/distributed/remote_worker_server.rb', line 33 def stop_all Thread.new do @workers.stop_all end end |
#workers_started? ⇒ Boolean
39 40 41 |
# File 'lib/deep_test/distributed/remote_worker_server.rb', line 39 def workers_started? @workers_started end |