2015-06-25 10:24:24 -07:00
|
|
|
#
|
2020-03-17 10:12:25 -07:00
|
|
|
# This file tells systemd how to run Sidekiq as a 24/7 long-running daemon.
|
2015-06-25 10:24:24 -07:00
|
|
|
#
|
|
|
|
# Customize this file based on your bundler location, app directory, etc.
|
2021-07-08 16:44:43 +02:00
|
|
|
#
|
|
|
|
# If you are going to run this as a user service (or you are going to use capistrano-sidekiq)
|
|
|
|
# Customize and copy this to ~/.config/systemd/user
|
|
|
|
# Then run:
|
|
|
|
# - systemctl --user enable sidekiq
|
|
|
|
# - systemctl --user {start,stop,restart} sidekiq
|
|
|
|
#
|
|
|
|
# If you are going to run this as a system service
|
2020-03-17 10:12:25 -07:00
|
|
|
# Customize and copy this into /usr/lib/systemd/system (CentOS) or /lib/systemd/system (Ubuntu).
|
|
|
|
# Then run:
|
2015-06-25 10:24:24 -07:00
|
|
|
# - systemctl enable sidekiq
|
2020-04-08 09:48:43 -07:00
|
|
|
# - systemctl {start,stop,restart} sidekiq
|
2015-06-25 10:24:24 -07:00
|
|
|
#
|
|
|
|
# This file corresponds to a single Sidekiq process. Add multiple copies
|
|
|
|
# to run multiple processes (sidekiq-1, sidekiq-2, etc).
|
|
|
|
#
|
2020-03-17 10:12:25 -07:00
|
|
|
# Use `journalctl -u sidekiq -rn 100` to view the last 100 lines of log output.
|
|
|
|
#
|
2015-06-25 10:24:24 -07:00
|
|
|
[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:
|
2019-10-12 11:02:55 -07:00
|
|
|
#
|
|
|
|
# https://www.freedesktop.org/software/systemd/man/systemd.service.html
|
|
|
|
# https://www.freedesktop.org/software/systemd/man/systemd.exec.html
|
|
|
|
#
|
|
|
|
# THOSE PAGES ARE CRITICAL FOR ANY LINUX DEVOPS WORK; read them multiple
|
|
|
|
# times! systemd is a critical tool for all developers to know and understand.
|
|
|
|
#
|
2015-06-25 10:24:24 -07:00
|
|
|
[Service]
|
2020-03-17 10:12:25 -07:00
|
|
|
#
|
2020-03-17 10:42:46 -07:00
|
|
|
# !!!! !!!! !!!!
|
2020-03-17 10:12:25 -07:00
|
|
|
#
|
2020-03-17 10:42:46 -07:00
|
|
|
# As of v6.0.6, Sidekiq automatically supports systemd's `Type=notify` and watchdog service
|
2020-03-25 09:01:01 -04:00
|
|
|
# monitoring. If you are using an earlier version of Sidekiq, change this to `Type=simple`
|
2020-04-20 05:49:37 -07:00
|
|
|
# and remove the `WatchdogSec` line.
|
2020-03-17 10:12:25 -07:00
|
|
|
#
|
2020-03-17 10:42:46 -07:00
|
|
|
# !!!! !!!! !!!!
|
2020-03-17 10:12:25 -07:00
|
|
|
#
|
|
|
|
Type=notify
|
2020-03-17 10:42:46 -07:00
|
|
|
# If your Sidekiq process locks up, systemd's watchdog will restart it within seconds.
|
2020-04-08 09:48:43 -07:00
|
|
|
WatchdogSec=10
|
2020-03-17 10:12:25 -07:00
|
|
|
|
2015-06-25 10:24:24 -07:00
|
|
|
WorkingDirectory=/opt/myapp/current
|
2016-08-28 23:45:07 +01:00
|
|
|
# If you use rbenv:
|
2020-01-08 08:59:24 -08:00
|
|
|
# ExecStart=/bin/bash -lc 'exec /home/deploy/.rbenv/shims/bundle exec sidekiq -e production'
|
2016-08-28 23:45:07 +01:00
|
|
|
# If you use the system's ruby:
|
2020-10-01 17:01:35 +05:30
|
|
|
# ExecStart=/usr/local/bin/bundle exec sidekiq -e production
|
|
|
|
# If you use rvm in production without gemset and your ruby version is 2.6.5
|
|
|
|
# ExecStart=/home/deploy/.rvm/gems/ruby-2.6.5/wrappers/bundle exec sidekiq -e production
|
2021-01-24 16:53:35 +05:00
|
|
|
# If you use rvm in production with gemset and your ruby version is 2.6.5
|
2021-05-19 17:09:36 +02:00
|
|
|
# ExecStart=/home/deploy/.rvm/gems/ruby-2.6.5@gemset-name/wrappers/bundle exec sidekiq -e production
|
|
|
|
# If you use rvm in production with gemset and ruby version/gemset is specified in .ruby-version,
|
|
|
|
# .ruby-gemsetor or .rvmrc file in the working directory
|
|
|
|
ExecStart=/home/deploy/.rvm/bin/rvm in /opt/myapp/current do bundle exec sidekiq -e production
|
2019-10-12 11:02:55 -07:00
|
|
|
|
2020-05-19 09:45:41 -07:00
|
|
|
# Use `systemctl kill -s TSTP sidekiq` to quiet the Sidekiq process
|
2019-10-12 11:02:55 -07:00
|
|
|
|
2021-07-08 16:44:43 +02:00
|
|
|
# Uncomment this if you are going to use this as a system service
|
|
|
|
# if using as a user service then leave commented out, or you will get an error trying to start the service
|
|
|
|
# !!! Change this to your deploy user account if you are using this as a system service !!!
|
|
|
|
# User=deploy
|
|
|
|
# Group=deploy
|
|
|
|
# UMask=0002
|
2015-06-25 10:24:24 -07:00
|
|
|
|
2018-04-29 17:58:19 -07:00
|
|
|
# Greatly reduce Ruby memory fragmentation and heap usage
|
|
|
|
# https://www.mikeperham.com/2018/04/25/taming-rails-memory-bloat/
|
|
|
|
Environment=MALLOC_ARENA_MAX=2
|
|
|
|
|
2015-06-25 10:24:24 -07:00
|
|
|
# if we crash, restart
|
|
|
|
RestartSec=1
|
2022-03-24 12:53:37 -04:00
|
|
|
Restart=always
|
2015-06-25 10:24:24 -07:00
|
|
|
|
2020-04-18 23:41:06 +02:00
|
|
|
# output goes to /var/log/syslog (Ubuntu) or /var/log/messages (CentOS)
|
2015-06-25 10:24:24 -07:00
|
|
|
StandardOutput=syslog
|
|
|
|
StandardError=syslog
|
|
|
|
|
|
|
|
# This will default to "bundler" if we don't specify it
|
|
|
|
SyslogIdentifier=sidekiq
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|