Module: Spring::Client::RunImpl

Included in:
Run
Defined in:
lib/spring-jruby/impl/fork/run.rb,
lib/spring-jruby/impl/pool/run.rb

Constant Summary collapse

TIMEOUT =
60
FORWARDED_SIGNALS =
%w(INT QUIT USR1 USR2 INFO) & Signal.list.keys

Instance Method Summary collapse

Instance Method Details

#forward_signal(sig, pid) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/spring-jruby/impl/fork/run.rb', line 37

def forward_signal(sig, pid)
  kill(sig, pid)
rescue Errno::ESRCH
  # If the application process is gone, then don't block the
  # signal on this process.
  trap(sig, 'DEFAULT')
  Process.kill(sig, Process.pid)
end

#forward_signals(pid) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/spring-jruby/impl/fork/run.rb', line 28

def forward_signals(pid)
  @signal_queue.each { |sig| kill sig, pid }

  RunImpl::FORWARDED_SIGNALS.each do |sig|
    trap(sig) { forward_signal sig, pid }
  end
rescue Errno::ESRCH
end

#queue_signalsObject



7
8
9
10
11
# File 'lib/spring-jruby/impl/fork/run.rb', line 7

def queue_signals
  RunImpl::FORWARDED_SIGNALS.each do |sig|
    trap(sig) { @signal_queue << sig }
  end
end

#run_on(application, screen_name) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/spring-jruby/impl/fork/run.rb', line 19

def run_on(application, pid)
  forward_signals(pid.to_i)
  status = application.read.to_i

  log "got exit status #{status}"

  exit status
end

#send_std_io_to(application) ⇒ Object



13
14
15
16
17
# File 'lib/spring-jruby/impl/fork/run.rb', line 13

def send_std_io_to(application)
  application.send_io STDOUT
  application.send_io STDERR
  application.send_io STDIN
end