Skip to content

Instantly share code, notes, and snippets.

@armandfardeau
Created July 13, 2018 12:33
Show Gist options
  • Select an option

  • Save armandfardeau/fafa2c77fdc337231a3e6dfea4839734 to your computer and use it in GitHub Desktop.

Select an option

Save armandfardeau/fafa2c77fdc337231a3e6dfea4839734 to your computer and use it in GitHub Desktop.
Register sidekiq as a service
which bundle
# /home/adminosp/.rbenv/shims/bundle
sudo nano /etc/systemd/system/sidekiq.service
sudo systemctl start sidekiq.service
sudo systemctl enable sidekiq.service
sudo systemctl status sidekiq.service
sudo service sidekiq status
# sudo systemctl daemon-reload
#
# systemd unit file for CentOS 7, Ubuntu 15.04
#
# Customize this file based on your bundler location, app directory, etc.
# Put this in /usr/lib/systemd/system (CentOS) or /lib/systemd/system (Ubuntu).
# 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).
#
# 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/adminosp/osp-app
# If you use rbenv:
ExecStart=/home/adminosp/.rbenv/shims/bundle exec sidekiq -e production
# If you use the system's ruby:
# ExecStart=/usr/local/bin/bundle exec sidekiq -e production
User=adminosp
Group=adminosp
UMask=0002
# if we crash, restart
RestartSec=5
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