Class: StaticRails::Server
- Inherits:
-
Object
- Object
- StaticRails::Server
- Defined in:
- lib/static-rails/server.rb
Instance Method Summary collapse
-
#initialize(site) ⇒ Server
constructor
A new instance of Server.
- #start ⇒ Object
- #started? ⇒ Boolean
- #wait_until_ready ⇒ Object
Constructor Details
#initialize(site) ⇒ Server
Returns a new instance of Server.
5 6 7 8 9 |
# File 'lib/static-rails/server.rb', line 5 def initialize(site) @site = site @ready = false @waits_for_connection = WaitsForConnection.new end |
Instance Method Details
#start ⇒ Object
11 12 13 14 15 16 |
# File 'lib/static-rails/server.rb', line 11 def start return if started? @pid = spawn_process set_at_exit_hook nil end |
#started? ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/static-rails/server.rb', line 18 def started? return false unless @pid.present? begin Process.getpgid(@pid) true rescue Errno::ESRCH @ready = false false end end |
#wait_until_ready ⇒ Object
30 31 32 33 34 |
# File 'lib/static-rails/server.rb', line 30 def wait_until_ready return if @ready @waits_for_connection.call(@site) @ready = true end |