0
@@ -71,31 +71,46 @@ module Merb
0
def kill(port, sig="INT")
0
Merb::BootLoader::BuildFramework.run
0
- port = "gid" if port == "all"
0
- pid = File.read(pid_file(port)).chomp.to_i
0
- kill_pid(sig, pid, pid_file(port))
0
- kill_pid(sig, -pid, pid_file(port))
0
+ if sig == 9 && port == "main"
0
+ Dir["#{Merb.log_path}" / "*.pid"].each do |file|
0
+ kill_pid(9, File.read(file).chomp.to_i, file)
0
+ pid = File.read(pid_file(port)).chomp.to_i
0
+ kill_pid(sig, pid, pid_file(port))
0
+ rescue Errno::EACCES => e
0
+ Merb.fatal! e.message, e
0
+ rescue Errno::ENOENT => e
0
+ Merb.fatal! "Could not find a PID file at #{pid_file(port)}", e
0
+ sig = Signal.list.invert[sig]
0
+ if sig == "KILL" && port == "main"
0
+ Merb.fatal! "Killed all PIDs with signal KILL"
0
+ Merb.fatal! "Killed #{port} with signal #{sig}"
0
- def kill_pid(sig, pid
)
0
+ def kill_pid(sig, pid
, file)
0
- FileUtils.rm(f) if File.exist?(f)
0
- puts "killed PID #{pid} with signal #{sig}"
0
+ FileUtils.rm(file) if File.exist?(file)
0
- puts "Failed to kill PID #{pid}: '#{sig}' is an invalid or unsupported signal number."
0
+ Merb.fatal! "Failed to kill PID #{pid}: '#{sig}' is an invalid " \
0
+ "or unsupported signal number."
0
-
puts "Failed to kill PID #{pid}: Insufficient permissions."
0
+
Merb.fatal! "Failed to kill PID #{pid}: Insufficient permissions."
0
- puts "Failed to kill PID #{pid}: Process is deceased or zombie."
0
+ Merb.fatal! "Failed to kill PID #{pid}: Process is " \
0
- puts "Failed to kill PID #{pid}: #{e.message}"
0
+ if !e.is_a?(SystemExit)
0
+ Merb.fatal! "Failed to kill PID #{pid}", e
0
@@ -186,12 +201,8 @@ module Merb
0
FileUtils.rm(pid_file(port)) if File.file?(pid_file(port))
0
- def store_details(port = nil, type = port ? "pid" : "gid")
0
- file = pid_file(port || type)
0
+ def store_details(port = nil)
0
FileUtils.mkdir_p(File.dirname(file))
0
rescue Errno::EACCES => e
0
@@ -199,7 +210,7 @@ module Merb
0
"but you did not have access.", e
0
Merb.logger.warn! "Storing #{type} file to #{file}..." if Merb::Config[:verbose]
0
- File.open(file, 'w'){ |f| f.write(Process.pid.to_s) }
0
+ File.open(file, 'w'){ |f| f.write(Process.pid.to_s) }
0
# Gets the pid file for the specified port.