Class: Spring::ApplicationManager
- Inherits:
-
Object
- Object
- Spring::ApplicationManager
- Includes:
- Mutex_m
- Defined in:
- lib/spring/application_manager.rb
Instance Attribute Summary collapse
-
#child ⇒ Object
readonly
Returns the value of attribute child.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Method Summary collapse
- #alive? ⇒ Boolean
-
#initialize(env) ⇒ ApplicationManager
constructor
A new instance of ApplicationManager.
- #restart ⇒ Object
- #run(client) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(env) ⇒ ApplicationManager
Returns a new instance of ApplicationManager.
11 12 13 14 |
# File 'lib/spring/application_manager.rb', line 11 def initialize(env) super() @env = env end |
Instance Attribute Details
#child ⇒ Object (readonly)
Returns the value of attribute child.
9 10 11 |
# File 'lib/spring/application_manager.rb', line 9 def child @child end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
9 10 11 |
# File 'lib/spring/application_manager.rb', line 9 def env @env end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
9 10 11 |
# File 'lib/spring/application_manager.rb', line 9 def pid @pid end |
Instance Method Details
#alive? ⇒ Boolean
28 29 30 |
# File 'lib/spring/application_manager.rb', line 28 def alive? @pid end |
#restart ⇒ Object
21 22 23 24 25 26 |
# File 'lib/spring/application_manager.rb', line 21 def restart # Restarting is a background operation. If it fails, we don't want # any terminal output. The user will see the output when they next # try to run a command. start_child(true) end |
#run(client) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/spring/application_manager.rb', line 32 def run(client) @client = client synchronize do start unless alive? begin child.send_io @client rescue Errno::EPIPE # EPIPE indicates child has died but has not been collected by the wait thread yet start child.send_io @client end end ensure @client.close @client = nil end |
#start ⇒ Object
16 17 18 19 |
# File 'lib/spring/application_manager.rb', line 16 def start start_child start_wait_thread end |