Skip to content

Instantly share code, notes, and snippets.

@YarikST
Created October 10, 2019 16:30
Show Gist options
  • Save YarikST/a5b41eca4d1928f6af665983324bfe6d to your computer and use it in GitHub Desktop.
Save YarikST/a5b41eca4d1928f6af665983324bfe6d to your computer and use it in GitHub Desktop.
touch /lib/systemd/system/sidekiq.service
# 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
After=syslog.target network.target redis-server.service
# 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]
Environment=APP_ROOT=/var/www/safepal RAILS_ENV=production
Environment=PID=/var/www/safepal/tmp/pids/sidekiq.pid LOG=/var/www/safepal/log/sidekiq.log
Type=simple
# If you use rbenv:
# ExecStart=/bin/bash -lc 'bundle exec sidekiq -e production'
# If you use the system's ruby:
PermissionsStartOnly=true
PIDFile=/var/www/safepal/tmp/pids/sidekiq.pid
ExecStart=/home/ubuntu/.rvm/gems/ruby-2.4.0@safepal/wrappers/bundle exec sidekiq
WorkingDirectory=/var/www/safepal
User=ubuntu
Group=ubuntu
UMask=0002
# 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
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