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