Method: Spring::ApplicationManager#run

Defined in:
lib/spring/application_manager.rb

#run(client) ⇒ Object

Returns the pid of the process running the command, or nil if the application process died.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/spring/application_manager.rb', line 59

def run(client)
  with_child do
    child.send_io client
    child.gets or raise Errno::EPIPE
  end

  pid = child.gets.to_i

  unless pid.zero?
    log "got worker pid #{pid}"
    pid
  end
rescue Errno::ECONNRESET, Errno::EPIPE => e
  log "#{e} while reading from child; returning no pid"
  nil
ensure
  client.close
end