Integrating With systemd

Next line of code:

require_relative "../lib/sidekiq/cli"

This code simply requires the Sidekiq::CLI class, which we'll discuss in a future post. In brief, this class is responsible for parsing command-line arguments, configuring Sidekiq, handling signals, and starting the Sidekiq process.

The integrate_with_systemd method

Next block of code:

def integrate_with_systemd
  return unless ENV["NOTIFY_SOCKET"]

  Sidekiq.configure_server do |config|
    config.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

We'll need the rest of this post to talk about what this method does. But first: what is the "systemd" that is referenced in this method name?

I wanted to be able to experiment with systemd and its command line interface, systemctl, but I use a Macbook (which runs on Unix) and apparently Unix doesn't support systemd. I