Permalink
Browse files

Updating script run semantics to ensure proper return status

  • Loading branch information...
1 parent c1f982e commit 6dfb406164ebd88f9e3a98e311f1403e80b73f90 @temujin9 temujin9 committed Oct 5, 2011
Showing with 8 additions and 11 deletions.
  1. +8 −11 lib/swineherd/script.rb
View
@@ -56,17 +56,14 @@ def local_cmd
# Default is to run with hadoop
#
def run mode=:hadoop
- case mode
- when :local then
- sh local_cmd do |res, ok|
- Log.info("Exit status was #{ok}")
- raise "Local mode script failed with exit status #{ok}" if ok != 0
- end
- when :hadoop then
- sh cmd do |res, ok|
- Log.info("Exit status was #{ok}")
- raise "Hadoop mode script failed with exit status #{ok}" if ok != 0
- end
+ command = case mode
+ when :local then local_cmd
+ when :hadoop then cmd
+ end
+
+ sh command do |ok, status|
+ Log.debug("Exit status was #{ok}, result was #{res}")
+ ok or raise "#{mode.to_s.capitalize} mode script failed with exit status #{ok}"
end
end

0 comments on commit 6dfb406

Please sign in to comment.