Class: Spring::Client::Stop
Constant Summary
collapse
- TIMEOUT =
2
Instance Attribute Summary
Attributes inherited from Command
#args, #env
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
call, #initialize
Class Method Details
.description ⇒ Object
8
9
10
|
# File 'lib/spring/client/stop.rb', line 8
def self.description
"Stop all spring processes for this project."
end
|
Instance Method Details
#call ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/spring/client/stop.rb', line 12
def call
if env.server_running?
timeout = Time.now + TIMEOUT
kill 'TERM'
sleep 0.1 until !env.server_running? || Time.now >= timeout
if env.server_running?
$stderr.puts "Spring did not stop; killing forcibly."
kill 'KILL'
else
puts "Spring stopped."
end
else
puts "Spring is not running"
end
end
|
#kill(sig) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/spring/client/stop.rb', line 29
def kill(sig)
pid = env.pid
Process.kill(sig, pid) if pid
rescue Errno::ESRCH
end
|