2012-01-16 16:14:47 -08:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
2015-06-22 09:14:55 -07:00
|
|
|
# Quiet some warnings we see when running in warning mode:
|
|
|
|
# RUBYOPT=-w bundle exec sidekiq
|
|
|
|
$TESTING = false
|
|
|
|
|
2022-01-26 15:33:23 -08:00
|
|
|
require_relative "../lib/sidekiq/cli"
|
2012-01-16 16:14:47 -08:00
|
|
|
|
2020-03-26 13:07:45 -07:00
|
|
|
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
|
|
|
|
|
2012-01-16 16:14:47 -08:00
|
|
|
begin
|
2012-03-08 20:58:51 -08:00
|
|
|
cli = Sidekiq::CLI.instance
|
2012-02-12 20:48:13 -08:00
|
|
|
cli.parse
|
2020-03-26 13:07:45 -07:00
|
|
|
|
|
|
|
integrate_with_systemd
|
|
|
|
|
2012-01-16 16:14:47 -08:00
|
|
|
cli.run
|
|
|
|
rescue => e
|
|
|
|
raise e if $DEBUG
|
2020-05-27 09:42:45 -07:00
|
|
|
if Sidekiq.error_handlers.length == 0
|
2022-01-26 15:33:23 -08:00
|
|
|
warn e.message
|
|
|
|
warn e.backtrace.join("\n")
|
2020-05-27 09:42:45 -07:00
|
|
|
else
|
|
|
|
cli.handle_exception e
|
|
|
|
end
|
|
|
|
|
2012-01-16 16:14:47 -08:00
|
|
|
exit 1
|
|
|
|
end
|