Skip to content

Commit

Permalink
Merge pull request #34 from bibendi/fix/on_error
Browse files Browse the repository at this point in the history
Fix Schked hanging when Redis fails
  • Loading branch information
bibendi authored Nov 15, 2022
2 parents a1873f9 + 9d97552 commit d47addd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion exe/schked
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bun/ruby
#!/usr/bin/ruby
# frozen_string_literal: true

require "bundler/setup"
Expand Down
2 changes: 1 addition & 1 deletion lib/schked/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Schked
VERSION = "1.1.0"
VERSION = "1.1.1"
end
7 changes: 6 additions & 1 deletion lib/schked/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ def define_callbacks
cfg = config

scheduler.define_singleton_method(:on_error) do |job, error|
cfg.logger.fatal("Task #{job.opts[:as] || job.job_id} failed with error: #{error.message}")
name = if job
job.opts[:as] || job.job_id
else
"unknown"
end
cfg.logger.fatal("Task #{name} failed with error: #{error.message}")
cfg.logger.error(error.backtrace.join("\n")) if error.backtrace

cfg.fire_callback(:on_error, job, error)
Expand Down

0 comments on commit d47addd

Please sign in to comment.