class DontStallMyProcess::Remote::RemoteApplicationController
Attributes
uri[R]
Public Class Methods
new(application)
click to toggle source
# File lib/dont-stall-my-process/remote/remote_application_controller.rb, line 9 def initialize(application) @applicarion = application @uri = "drbunix:///tmp/dsmp-#{Process.ppid}-controller-#{Process.pid}" @server = DRb.start_service(uri, self) end
Public Instance Methods
alive?()
click to toggle source
# File lib/dont-stall-my-process/remote/remote_application_controller.rb, line 50 def alive? true end
start_service(klass, opts)
click to toggle source
# File lib/dont-stall-my-process/remote/remote_application_controller.rb, line 16 def start_service(klass, opts) # Instantiate the main class now to get early failures. instance = klass.new # Start the main DRb service. @proxy = RemoteProxy.new(opts, instance) # Set subprocess name if requested. RemoteApplication.update_process_name(klass.name.to_s) # Return the DRb URI. @proxy.uri end
stop_application()
click to toggle source
# File lib/dont-stall-my-process/remote/remote_application_controller.rb, line 30 def stop_application # Kill remaining DRb servers, shouldn't be any at this point. RemoteProxy.each_proxy { |proxy| __destroy.destroy } Thread.new do # Wait for DRb answer package to be sent. sleep 0.2 # Kill our own DRb server. @server.stop_service FileUtils.rm_f(@uri) # Let DRb resolve its pthread mutexes and stuff. sleep 0.2 # Wake up the main application thread. @application.stop! end end