Last active
June 28, 2022 23:15
-
-
Save mkhuda/132787f9d54890a183d665eb4560f196 to your computer and use it in GitHub Desktop.
Sidekiq service auto start for Ubuntu 16.04 using Systemd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Sidekiq auto start using systemd unit file for Ubuntu 16.04 | |
# | |
# Put this in /lib/systemd/system (Ubuntu). | |
# Run: | |
# 1. systemctl enable sidekiq (to enable sidekiq service) | |
# 2. systemctl {start,stop,restart} sidekiq (to start sidekiq service) | |
# | |
# This file corresponds to a single Sidekiq process. Add multiple copies | |
# to run multiple processes (sidekiq-1, sidekiq-2, etc). | |
# | |
# See Inspeqtor's Systemd wiki page for more detail about Systemd: | |
# https://github.com/mperham/inspeqtor/wiki/Systemd | |
# | |
[Unit] | |
Description=sidekiq | |
# start us only once the network and logging subsystems are available, | |
# consider adding redis-server.service if Redis is local and systemd-managed. | |
After=syslog.target network.target | |
# See these pages for lots of options: | |
# http://0pointer.de/public/systemd-man/systemd.service.html | |
# http://0pointer.de/public/systemd-man/systemd.exec.html | |
[Service] | |
Type=simple | |
WorkingDirectory=/home/Public/Rails/your-rails-app | |
# If you use rbenv or rvm: | |
ExecStart=/bin/bash -lc 'bundle exec sidekiq -e production' | |
# If you use the system's ruby: | |
# ExecStart=bundle exec sidekiq -e production | |
User=your-username | |
Group=your-username | |
UMask=0002 | |
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To get
cap production sidekiq:start
to work, I followed this advice and also put the service file in/lib/systemd/user
instead of/lib/systemd/system
. But putting it in theuser
directory isn't really a fix: the service doesn't continue running when the non-root user isn't logged in.Why would it not work for me in the system folder when it appears to have worked for others? Why did I need to remove
User
andGroup
when they specify my deploy user?