Class: Cangrejo::Support::Launcher
- Inherits:
-
Object
- Object
- Cangrejo::Support::Launcher
- Defined in:
- lib/cangrejo/support/launcher.rb
Defined Under Namespace
Classes: LaunchTimeout
Constant Summary collapse
- SPAWN_TIMEOUT =
5- KILL_TIMEOUT =
5
Instance Method Summary collapse
- #host ⇒ Object
-
#initialize(_path, _options = {}) ⇒ Launcher
constructor
A new instance of Launcher.
- #kill ⇒ Object
- #launch ⇒ Object
Constructor Details
#initialize(_path, _options = {}) ⇒ Launcher
Returns a new instance of Launcher.
16 17 18 19 20 21 |
# File 'lib/cangrejo/support/launcher.rb', line 16 def initialize(_path, ={}) @path = _path @timeout = .fetch(:timeout, SPAWN_TIMEOUT) @argv = .fetch(:argv, []) select_socket_file end |
Instance Method Details
#host ⇒ Object
23 24 25 |
# File 'lib/cangrejo/support/launcher.rb', line 23 def host "unix://#{@socket_file}" end |
#kill ⇒ Object
34 35 36 |
# File 'lib/cangrejo/support/launcher.rb', line 34 def kill safe_kill @pid unless @pid.nil? end |
#launch ⇒ Object
27 28 29 30 31 32 |
# File 'lib/cangrejo/support/launcher.rb', line 27 def launch gem_path = File.join(@path, 'Gemfile') # TODO: for some reason, the gemfile path must be specified here, maybe because of rbenv? @pid = Process.spawn({ 'BUNDLE_GEMFILE' => gem_path }, "bin/crabfarm s --host=#{host} #{@argv.join(' ')}", chdir: @path, pgroup: true) wait_for_socket end |