Class: WavesLib::RootWrapper
- Inherits:
-
Object
- Object
- WavesLib::RootWrapper
- Extended by:
- T::Sig
- Defined in:
- lib/waves_lib/root_wrapper.rb
Overview
Main class for creating connection
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(node_bin_path = "node") ⇒ RootWrapper
constructor
A new instance of RootWrapper.
Constructor Details
#initialize(node_bin_path = "node") ⇒ RootWrapper
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/waves_lib/root_wrapper.rb', line 14 def initialize(node_bin_path = "node") entrypoint = File.join(__dir__ || "", "..", "..", "js", "worker.js") @port = T.let(find_empty_port, Integer) cmd = "#{node_bin_path} #{entrypoint}" env = { "PORT" => @port.to_s } @pid = T.let(Process.spawn(env, cmd), Integer) wait_for_server_ready create_wrappers end |
Instance Method Details
#destroy ⇒ Object
30 31 32 33 |
# File 'lib/waves_lib/root_wrapper.rb', line 30 def destroy @socket&.close Process.kill("HUP", @pid) end |