2015-06-25 10:24:24 -07:00
|
|
|
#
|
2019-10-12 11:02:55 -07:00
|
|
|
# systemd unit file for CentOS 7+, Ubuntu 15.04+
|
2015-06-25 10:24:24 -07:00
|
|
|
#
|
|
|
|
# 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
|
2019-10-12 11:02:55 -07:00
|
|
|
# - systemctl {start,stop,restart,reload} 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).
|
|
|
|
#
|
|
|
|
[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-01-14 17:45:59 +01:00
|
|
|
# You may want to use
|
|
|
|
# Type=notify
|
|
|
|
# to ensure service is not marked as started before it actually did.
|
|
|
|
# Include sd_notify gem to send a message on sidekiq startup like
|
|
|
|
# Sidekiq.configure_server do |config|
|
|
|
|
# config.on(:startup) { SdNotify.ready }
|
|
|
|
# end
|
|
|
|
# to let systemd know when the service is actually started.
|
2015-06-25 10:24:24 -07:00
|
|
|
Type=simple
|
|
|
|
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:
|
2015-12-18 13:52:26 -08:00
|
|
|
ExecStart=/usr/local/bin/bundle exec sidekiq -e production
|
2019-10-12 11:02:55 -07:00
|
|
|
|
|
|
|
# use `systemctl reload sidekiq` to send the quiet signal to Sidekiq
|
|
|
|
# at the start of your deploy process.
|
|
|
|
ExecReload=/usr/bin/kill -TSTP $MAINPID
|
|
|
|
|
2015-06-25 10:24:24 -07:00
|
|
|
User=deploy
|
|
|
|
Group=deploy
|
|
|
|
UMask=0002
|
|
|
|
|
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
|
|
|
|
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
|