Module: Rails::DSL::Commands::Helpers

Defined in:
lib/rails-dsl/kill_server.rb

Class Method Summary collapse

Class Method Details

.kill(opid_path) ⇒ Object Also known as: kill!



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rails-dsl/kill_server.rb', line 8

def kill(opid_path)

  opid= File.read(opid_path)
  Process.kill 'HUP', opid.to_i

  $stdout.puts "At pid: #{opid} the app is killed with pidfile: #{opid_path}"
  true
rescue Errno::ENOENT
  $stdout.puts "#{opid_path} did not exist: Errno::ENOENT"
  true
rescue Errno::ESRCH
  $stdout.puts "The process #{opid} did not exist: Errno::ESRCH"                
  true
rescue Errno::EPERM
  $stderr.puts "Lack of privileges to manage the process #{opid}: Errno::EPERM" 
  false
rescue ::Exception => e
  $stderr.puts "While signaling the PID, unexpected #{e.class}: #{e}"           
  false
end