1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
mperham--sidekiq/bin/sidekiq
Takashi M cb7c3a7530
Use error handler(s) from CLI launch failure (#4581)
* Use error handler(s) from CLI launch failure

* Fix comparison operator
2020-05-27 09:42:45 -07:00

42 lines
853 B
Ruby
Executable file

#!/usr/bin/env ruby
# Quiet some warnings we see when running in warning mode:
# RUBYOPT=-w bundle exec sidekiq
$TESTING = false
require_relative '../lib/sidekiq/cli'
def integrate_with_systemd
return unless ENV["NOTIFY_SOCKET"]
Sidekiq.configure_server do |config|
Sidekiq.logger.info "Enabling systemd notification integration"
require "sidekiq/sd_notify"
config.on(:startup) do
Sidekiq::SdNotify.ready
end
config.on(:shutdown) do
Sidekiq::SdNotify.stopping
end
Sidekiq.start_watchdog if Sidekiq::SdNotify.watchdog?
end
end
begin
cli = Sidekiq::CLI.instance
cli.parse
integrate_with_systemd
cli.run
rescue => e
raise e if $DEBUG
if Sidekiq.error_handlers.length == 0
STDERR.puts e.message
STDERR.puts e.backtrace.join("\n")
else
cli.handle_exception e
end
exit 1
end