Permalink
Browse files

Fix reporting for an error scenario whereby launchctl crashes / exits…

… unexpectedly
  • Loading branch information...
1 parent f9adb6b commit 3352fd2d1597f8e2a488a398eac0d0364cb115f3 @dreamcat4 committed Aug 18, 2010
Showing with 10 additions and 3 deletions.
  1. +10 −3 lib/launchr/service.rb
View
@@ -404,7 +404,11 @@ def start
end
if result[:status].exitstatus != 0
- puts "Launchctl exited with code #{result[:status].exitstatus} when trying to start \"#{job.label}\""
+ if result[:status].exitstatus
+ puts "Launchctl exited with code #{result[:status].exitstatus} when trying to stop \"#{job.label}\""
+ else
+ puts "Launchctl terminated unexpectedly with #{result[:status].inspect}"
+ end
puts result[:stdout] unless result[:stdout].empty?
puts result[:stderr] unless result[:stderr].empty?
end
@@ -428,7 +432,11 @@ def stop
result = launchctl :unload, job
if result[:status].exitstatus != 0
- puts "Launchctl exited with code #{result[:status].exitstatus} when trying to stop \"#{job.label}\""
+ if result[:status].exitstatus
+ puts "Launchctl exited with code #{result[:status].exitstatus} when trying to stop \"#{job.label}\""
+ else
+ puts "Launchctl terminated unexpectedly with #{result[:status].inspect}"
+ end
puts result[:stdout] unless result[:stdout].empty?
puts result[:stderr] unless result[:stderr].empty?
end
@@ -468,7 +476,6 @@ def self.header
out = []
out << sprintf("%-20.20s %-30.30s %-10.10s %-20.20s", "Service", "Launchd job label", "Status", "Level")
out << sprintf("%-20.20s %-30.30s %-10.10s %-20.20s", "-------", "-----------------", "------", "-----")
- # out << sprintf("%-20.20s %-30.30s %-10.10s %-20.20s", "=======", "=================", "======", "=====")
out.join("\n")
end

0 comments on commit 3352fd2

Please sign in to comment.