https://github.com/mperham/sidekiq
Raw File
Tip revision: fba25e1f64635d0180e62c5df32f8d94d7fdacb3 authored by Mike Perham on 08 April 2022, 19:11:19 UTC
Merge branch '7-0' into xa
Tip revision: fba25e1
sidekiq
#!/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
    warn e.message
    warn e.backtrace.join("\n")
  else
    cli.handle_exception e
  end

  exit 1
end
back to top