public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
merb -k works right
wycats (author)
Tue Sep 30 08:10:14 -0700 2008
commit  59a2e88f92eaeab86817b933d63d272e02f17213
tree    3eae16223f65b9db1661be9cd59e1045e11aad31
parent  0d0459cde49d7602b06a8a09a4379dbf3aac17d3
...
70
71
72
73
74
75
76
77
78
79
80
 
 
 
 
81
82
83
84
85
 
 
86
 
87
88
89
 
90
91
92
...
94
95
96
97
 
98
 
 
99
100
101
...
107
108
109
 
 
 
 
110
111
112
...
70
71
72
 
 
 
 
 
 
 
 
73
74
75
76
77
 
 
 
 
78
79
80
81
82
83
84
85
86
87
88
...
90
91
92
 
93
94
95
96
97
98
99
...
105
106
107
108
109
110
111
112
113
114
0
@@ -70,23 +70,19 @@ module Merb
0
       # processes.
0
       def kill(port, sig="INT")
0
         Merb::BootLoader::BuildFramework.run
0
-        begin
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
-            end
0
-          else
0
-            pid = File.read(pid_file(port)).chomp.to_i
0
-            kill_pid(sig, pid, pid_file(port))
0
+        if sig == 9 && port == "main"
0
+          kill_pid("INT", pid_file("main"))
0
+          Dir["#{Merb.log_path}" / "*.pid"].each do |file|
0
+            kill_pid(9, file)
0
           end
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
+        else
0
+          kill_pid(sig, pid_file(port))
0
         end
0
+
0
         if sig.is_a?(Integer)
0
           sig = Signal.list.invert[sig]
0
         end
0
+
0
         if sig == "KILL" && port == "main"
0
           Merb.fatal! "Killed all PIDs with signal KILL"
0
         else
0
@@ -94,8 +90,10 @@ module Merb
0
         end
0
       end
0
       
0
-      def kill_pid(sig, pid, file)
0
+      def kill_pid(sig, file)
0
         begin
0
+          pid = File.read(file).chomp.to_i
0
+          Merb.logger.warn! "Killing pid #{pid}"
0
           Process.kill(sig, pid)
0
           FileUtils.rm(file) if File.exist?(file)
0
         rescue Errno::EINVAL
0
@@ -107,6 +105,10 @@ module Merb
0
           FileUtils.rm file
0
           Merb.fatal! "Failed to kill PID #{pid}: Process is " \
0
             "deceased or zombie."
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 #{file}", e
0
         rescue Exception => e
0
           if !e.is_a?(SystemExit)
0
             Merb.fatal! "Failed to kill PID #{pid}", e

Comments