Class: Crabfarm::PhantomRunner
- Inherits:
-
Object
- Object
- Crabfarm::PhantomRunner
- Defined in:
- lib/crabfarm/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.
9 10 11 12 |
# File 'lib/crabfarm/phantom_runner.rb', line 9 def initialize(_config={}) @config = _config; @process = nil end |
Instance Method Details
#port ⇒ Object
14 15 16 |
# File 'lib/crabfarm/phantom_runner.rb', line 14 def port @config[:port] end |
#start ⇒ Object
18 19 20 21 22 |
# File 'lib/crabfarm/phantom_runner.rb', line 18 def start logger.info "Starting phantomjs in port #{port}" @process = spawn_phantomjs logger.info "Phantomjs started (PID: #{@process.pid})" end |
#stop ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/crabfarm/phantom_runner.rb', line 24 def stop unless @process.nil? logger.info "Stopping phantomjs (PID: #{@process.pid})" @process.stop @process = nil logger.info "Phantomjs stopped" end end |