Skip to content

Instantly share code, notes, and snippets.

@brycejohnston
Last active March 18, 2021 11:51
Show Gist options
  • Save brycejohnston/b1a11d254fdde007a1bc715dcb5319d5 to your computer and use it in GitHub Desktop.
Save brycejohnston/b1a11d254fdde007a1bc715dcb5319d5 to your computer and use it in GitHub Desktop.
Sidekiq systemd service for Debian
#
# systemd unit file for Debian
#
# Put this in /lib/systemd/system
# Run:
# - systemctl enable sidekiq
# - systemctl {start,stop,restart} sidekiq
#
# This file corresponds to a single Sidekiq process. Add multiple copies
# to run multiple processes (sidekiq-1, sidekiq-2, etc).
#
[Unit]
Description=sidekiq
# start sidekiq only once the network, logging subsystems and local redis instance are available
After=syslog.target network.target redis-server.service postgresql.service
[Service]
# change path to bundle if not using rbenv
Type=simple
WorkingDirectory=/home/deploy/myapp/current
User=deploy
Group=deploy
UMask=0002
ExecStart=/home/deploy/.rbenv/shims/bundle exec sidekiq -e production -C config/sidekiq.yml -L log/sidekiq.log
ExecStop=/home/deploy/.rbenv/shims/bundle exec sidekiqctl stop /home/deploy/myapp/current/pids/sidekiq.pid
# if we crash, restart
RestartSec=1
Restart=on-failure
# output goes to /var/log/syslog
StandardOutput=syslog
StandardError=syslog
# This will default to "bundler" if we don't specify it
SyslogIdentifier=sidekiq
[Install]
WantedBy=multi-user.target
@PiotrBracha
Copy link

This does't work: ExecStart=/home/deploy/.rbenv/shims/bundle exec sidekiq -e production -C config/sidekiq.yml -L log/sidekiq.log
This works: ExecStart=/bin/bash -lc 'exec /home/deploy/.rbenv/shims/bundle exec sidekiq -L log/sidekiq.log -e production -P tmp/sidekiq.pid'

It's about /bin/bash -lc at the beginning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment