Class: Crabfarm::CrabtrapRunner
- Inherits:
-
Object
- Object
- Crabfarm::CrabtrapRunner
- Defined in:
- lib/crabfarm/crabtrap_runner.rb
Instance Method Summary collapse
-
#initialize(_config = {}) ⇒ CrabtrapRunner
constructor
A new instance of CrabtrapRunner.
- #mode ⇒ Object
- #port ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(_config = {}) ⇒ CrabtrapRunner
Returns a new instance of CrabtrapRunner.
6 7 8 9 |
# File 'lib/crabfarm/crabtrap_runner.rb', line 6 def initialize(_config={}) @config = _config; @pid = nil end |
Instance Method Details
#mode ⇒ Object
15 16 17 |
# File 'lib/crabfarm/crabtrap_runner.rb', line 15 def mode @config.fetch(:mode, :pass).to_sym end |
#port ⇒ Object
11 12 13 |
# File 'lib/crabfarm/crabtrap_runner.rb', line 11 def port @config[:port] # TODO: maybe select port dynamically... end |
#start ⇒ Object
19 20 21 22 |
# File 'lib/crabfarm/crabtrap_runner.rb', line 19 def start @pid = Process.spawn({}, crabtrap_cmd) wait_for_server end |
#stop ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/crabfarm/crabtrap_runner.rb', line 24 def stop unless @pid.nil? Process.kill("INT", @pid) Process.wait @pid @pid = nil end end |