Skip to content

Commit

Permalink
Merge pull request #68 from SonicGarden/fix-exit-status
Browse files Browse the repository at this point in the history
[review] 常に終了ステータス0を返すようにするためのcliオプションを追加
  • Loading branch information
aki77 authored Nov 23, 2023
2 parents 34cf625 + c8721c7 commit b886777
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions lib/jobmon/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def client

def run_command
raise 'Command is empty.' if options[:cmd].nil?

name = options.fetch(:name) { options[:cmd].split(' ', 2).first }

client.job_monitor(name, estimate_time) do
Expand All @@ -44,6 +45,15 @@ def run_task
Rake.application.run(task_argv)
end
0

# NOTE: Rake.application.runから投げられる例外は全てSystemExitとなるため
rescue SystemExit, StandardError => e
if options[:suppress_errors]
Jobmon.configuration.error_handle.call(e)
return 0
end

raise e
end

def estimate_time
Expand All @@ -69,6 +79,9 @@ def opt
opts.on('-c', '--cmd [cmd]') do |cmd|
@options[:cmd] = cmd if cmd
end
opts.on('-s', '--suppress-errors') do
@options[:suppress_errors] = true
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/jobmon/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Jobmon
VERSION = '1.8.0'
VERSION = '1.9.0'
end

0 comments on commit b886777

Please sign in to comment.