vol1ura/Sat_9am_5km

View on GitHub
deploy/sidekiq.service.example

Summary

Maintainability
Test Coverage
# This example file is based on https://github.com/mperham/sidekiq/tree/main/examples/systemd
# To run this as a system service copy file into /lib/systemd/system (Ubuntu).
# scp sidekiq.service root@host_ip:/lib/systemd/system
# Then 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).
#
# Use `journalctl -u sidekiq -rn 100` to view the last 100 lines of log output.
#
[Unit]
Description=Sidekiq for s95 (production)
# 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 redis-server.service

[Service]
User=<user>
Group=<user>
UMask=0002

Type=notify
# If your Sidekiq process locks up, systemd's watchdog will restart it within seconds.
WatchdogSec=10

WorkingDirectory=/home/<user>/path/to/app/current
ExecStart=/home/<user>/.rbenv/bin/rbenv exec bundle exec sidekiq -e production -C config/sidekiq.yml

# Use `systemctl kill -s TSTP sidekiq` to quiet the Sidekiq process

# Greatly reduce Ruby memory fragmentation and heap usage
# https://www.mikeperham.com/2018/04/25/taming-rails-memory-bloat/
Environment=MALLOC_ARENA_MAX=2

# if we crash, restart
Restart=on-failure
RestartSec=3

# output goes to /var/log/syslog (Ubuntu) or /var/log/messages (CentOS)
StandardOutput=append:/path/to/app/shared/log/sidekiq.log
StandardError=append:/path/to/app/shared/log/sidekiq.error.log

SyslogIdentifier=sidekiq

[Install]
WantedBy=default.target