Class: Explorer::Servers
- Inherits:
-
Object
- Object
- Explorer::Servers
- Defined in:
- lib/explorer/servers.rb
Overview
TODO: Hostmap should be it’s own actor; immutable; or thread-safe
Instance Attribute Summary collapse
-
#dns_port ⇒ Object
readonly
Returns the value of attribute dns_port.
-
#hostmap ⇒ Object
readonly
Returns the value of attribute hostmap.
-
#http_port ⇒ Object
readonly
Returns the value of attribute http_port.
-
#https_port ⇒ Object
readonly
Returns the value of attribute https_port.
-
#ipc_file ⇒ Object
readonly
Returns the value of attribute ipc_file.
-
#log_watcher ⇒ Object
readonly
Returns the value of attribute log_watcher.
-
#process_manager ⇒ Object
readonly
Returns the value of attribute process_manager.
Instance Method Summary collapse
-
#initialize(dns_port: 23400, http_port: 23401, https_port: 23402, hostmap: {}, ipc_file: '/tmp/explorer_ipc') ⇒ Servers
constructor
A new instance of Servers.
- #run ⇒ Object
- #run! ⇒ Object
- #terminate ⇒ Object
Constructor Details
#initialize(dns_port: 23400, http_port: 23401, https_port: 23402, hostmap: {}, ipc_file: '/tmp/explorer_ipc') ⇒ Servers
Returns a new instance of Servers.
9 10 11 12 13 14 15 16 17 |
# File 'lib/explorer/servers.rb', line 9 def initialize dns_port: 23400, http_port: 23401, https_port: 23402, hostmap: {}, ipc_file: '/tmp/explorer_ipc' @dns_port = dns_port @http_port = http_port @https_port = https_port @ipc_file = ipc_file @hostmap = hostmap @log_watcher = LogWatcher.new @process_manager = ProcessManager.new log_watcher end |
Instance Attribute Details
#dns_port ⇒ Object (readonly)
Returns the value of attribute dns_port.
6 7 8 |
# File 'lib/explorer/servers.rb', line 6 def dns_port @dns_port end |
#hostmap ⇒ Object (readonly)
Returns the value of attribute hostmap.
7 8 9 |
# File 'lib/explorer/servers.rb', line 7 def hostmap @hostmap end |
#http_port ⇒ Object (readonly)
Returns the value of attribute http_port.
6 7 8 |
# File 'lib/explorer/servers.rb', line 6 def http_port @http_port end |
#https_port ⇒ Object (readonly)
Returns the value of attribute https_port.
6 7 8 |
# File 'lib/explorer/servers.rb', line 6 def https_port @https_port end |
#ipc_file ⇒ Object (readonly)
Returns the value of attribute ipc_file.
6 7 8 |
# File 'lib/explorer/servers.rb', line 6 def ipc_file @ipc_file end |
#log_watcher ⇒ Object (readonly)
Returns the value of attribute log_watcher.
7 8 9 |
# File 'lib/explorer/servers.rb', line 7 def log_watcher @log_watcher end |
#process_manager ⇒ Object (readonly)
Returns the value of attribute process_manager.
7 8 9 |
# File 'lib/explorer/servers.rb', line 7 def process_manager @process_manager end |
Instance Method Details
#run ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/explorer/servers.rb', line 19 def run # Setup trap read, write = IO.pipe trap(:INT) { write.puts } # Start servers run! IO.select([read]) # Wait for trap # Cleanup terminate end |
#run! ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/explorer/servers.rb', line 39 def run! @group = Celluloid::SupervisionGroup.new do |group| group.supervise_as :dns, Server::DNS, dns_port group.supervise_as :http, Server::HTTP, http_port, hostmap group.supervise_as :https, Server::HTTPS, https_port, hostmap group.supervise_as :ipc, Server::IPC, ipc_file, self end end |
#terminate ⇒ Object
33 34 35 36 37 |
# File 'lib/explorer/servers.rb', line 33 def terminate @group.terminate if @group @process_manager.terminate if @process_manager # TODO: @log_watcher.terminate if @log_watcher end |