Class: JstdRunner::Server
- Inherits:
-
Object
- Object
- JstdRunner::Server
- Includes:
- Monitorable
- Defined in:
- lib/jstd-runner/server.rb
Defined Under Namespace
Classes: StartupError, StopError
Constant Summary collapse
- JAR =
File.("../JsTestDriver-1.3.3d.jar", __FILE__)
- LAUNCH_TIMEOUT =
this is huge, but I’ve seen it happen
120
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(port, jar = nil) ⇒ Server
constructor
A new instance of Server.
- #restart ⇒ Object
- #running? ⇒ Boolean
- #start ⇒ Object
- #stop ⇒ Object
Methods included from Monitorable
Constructor Details
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
14 15 16 |
# File 'lib/jstd-runner/server.rb', line 14 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
14 15 16 |
# File 'lib/jstd-runner/server.rb', line 14 def port @port end |
Instance Method Details
#restart ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/jstd-runner/server.rb', line 38 def restart @restarting = true Log.info "restarting server" stop rescue nil @process = nil start @restarting = false end |
#running? ⇒ Boolean
56 57 58 |
# File 'lib/jstd-runner/server.rb', line 56 def running? process.alive? && immediate_poller.connected? end |
#start ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/jstd-runner/server.rb', line 23 def start Log.info "starting JsTestDriver from #{@jar}" if immediate_poller.connected? raise StartupError, "JsTestDriver already running on #{@host}:#{@port}" end process.start unless long_poller.connected? process.stop rescue nil raise StartupError, "could not launch JsTestDriver server on #{@host}:#{@port} within #{LAUNCH_TIMEOUT} seconds" end end |
#stop ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/jstd-runner/server.rb', line 47 def stop Log.info "stopping JsTestDriver" process.stop unless long_poller.closed? raise StopError, "could not stop JsTestDriver server on port #{@host}:#{@port} witin #{LAUNCH_TIMEOUT} seconds" end end |