def kill(port, sig=9)
Merb::BootLoader::BuildFramework.run
begin
pidfiles = port == "all" ?
pid_files : [ pid_file(port) ]
pidfiles.each do |f|
pid = IO.read(f).chomp.to_i
begin
Process.kill(sig, pid)
FileUtils.rm(f) if File.exist?(f)
puts "killed PID #{pid} with signal #{sig}"
rescue Errno::EINVAL
puts "Failed to kill PID #{pid}: '#{sig}' is an invalid or unsupported signal number."
rescue Errno::EPERM
puts "Failed to kill PID #{pid}: Insufficient permissions."
rescue Errno::ESRCH
puts "Failed to kill PID #{pid}: Process is deceased or zombie."
FileUtils.rm f
rescue Exception => e
puts "Failed to kill PID #{pid}: #{e.message}"
end
end
ensure
exit
end
end