Class: RackCheck::ServerManager
- Inherits:
-
Object
- Object
- RackCheck::ServerManager
- Includes:
- Helpers
- Defined in:
- lib/rack_check/server_manager.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#ru_file ⇒ Object
readonly
Returns the value of attribute ru_file.
Instance Method Summary collapse
-
#initialize(context, ru_file) ⇒ ServerManager
constructor
A new instance of ServerManager.
- #run ⇒ Object
- #stop ⇒ Object
Methods included from Helpers
Constructor Details
#initialize(context, ru_file) ⇒ ServerManager
Returns a new instance of ServerManager.
10 11 12 13 14 |
# File 'lib/rack_check/server_manager.rb', line 10 def initialize(context, ru_file) @ru_file = ru_file @stop_var = Concurrent::MVar.new @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
8 9 10 |
# File 'lib/rack_check/server_manager.rb', line 8 def context @context end |
#ru_file ⇒ Object (readonly)
Returns the value of attribute ru_file.
8 9 10 |
# File 'lib/rack_check/server_manager.rb', line 8 def ru_file @ru_file end |
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rack_check/server_manager.rb', line 16 def run Thread.new do begin with_environment(ru_file) do |dir| @pid = Process.spawn context.app_server_command, in: '/dev/null', out: '/dev/null', err: '/dev/null', chdir: dir @stop_var.take Process.kill 'TERM', @pid Process.wait @pid @pid = nil end rescue => e $stderr.puts "App server thread exited: #{e.message}\n#{e.backtrace.join("\n")}" end end port = wait_for_port "http://localhost:#{port}" end |
#stop ⇒ Object
40 41 42 43 44 45 |
# File 'lib/rack_check/server_manager.rb', line 40 def stop @stop_var.put true while check_port sleep 0.1 end end |