Class: Crabfarm::Support::PhantomRunner
- Inherits:
-
Object
- Object
- Crabfarm::Support::PhantomRunner
- Defined in:
- lib/crabfarm/support/phantom_runner.rb
Constant Summary collapse
- PHANTOM_START_TM =
seconds
5
Instance Method Summary collapse
-
#initialize(_config = {}) ⇒ PhantomRunner
constructor
A new instance of PhantomRunner.
- #port ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(_config = {}) ⇒ PhantomRunner
Returns a new instance of PhantomRunner.
11 12 13 14 |
# File 'lib/crabfarm/support/phantom_runner.rb', line 11 def initialize(_config={}) @config = _config; @process = nil end |
Instance Method Details
#port ⇒ Object
16 17 18 |
# File 'lib/crabfarm/support/phantom_runner.rb', line 16 def port @config[:port] end |
#start ⇒ Object
20 21 22 23 24 |
# File 'lib/crabfarm/support/phantom_runner.rb', line 20 def start logger.info "Starting phantomjs in port #{port}" @process = spawn_phantomjs logger.info "Phantomjs started (PID: #{@process.pid})" end |
#stop ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/crabfarm/support/phantom_runner.rb', line 26 def stop unless @process.nil? logger.info "Stopping phantomjs (PID: #{@process.pid})" @process.stop @process = nil logger.info "Phantomjs stopped" end end |