Skip to content

Instantly share code, notes, and snippets.

@beneggett
Forked from sj26/sidekiq.service
Created November 11, 2022 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beneggett/270fdcbf20a86faaca1b51f0a7cd9618 to your computer and use it in GitHub Desktop.
Save beneggett/270fdcbf20a86faaca1b51f0a7cd9618 to your computer and use it in GitHub Desktop.
systemd unit files for multiple sidekiq workers
[Unit]
Description=Sidekiq workers
# start as many workers as you want here
Wants=sidekiq@1.service
Wants=sidekiq@2.service
# ...
[Service]
Type=oneshot
ExecStart=/bin/true
RemainAfterExit=true
[Unit]
Description=Sidekiq worker %I
# restarts/stops with sidekiq
PartOf=sidekiq.service
After=network.target
[Service]
User=app
Group=app
UMask=0002
WorkingDirectory=/app
ExecStart=/app/bin/sidekiq -C config/sidekiq.yml -i "%I" -e production
# restart & stop send TERM to main process, wait up to 30 seconds, then KILL if still running
KillMode=mixed
TimeoutStopSec=30
# restart on non-zero exit or other failure after 5 seconds
Restart=on-failure
RestartSec=5
# don't create a new systemd.slice per instance
Slice=system.slice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment