# /etc/init/sidekiq.conf - Sidekiq config# This example config should work with Ubuntu 12.04+. It# allows you to manage multiple Sidekiq instances with# Upstart, Ubuntu's native service management tool.## See workers.conf for how to manage all Sidekiq instances at once.## Save this config as /etc/init/sidekiq.conf then mange sidekiq with:# sudo start sidekiq# sudo stop sidekiq# sudo status sidekiq## or use the service command:# sudo service sidekiq {start,stop,restart,status}#description"Sidekiq Background Worker"# This starts upon bootup and stops on shutdownstartonrunlevel[2345]stoponrunlevel[06]# change to match your deployment usersetuiddeploysetgiddeployenvHOME=/home/deployrespawnrespawnlimit330# TERM is sent by sidekiqctl when stopping sidekiq. Without declaring these as# normal exit codes, it just respawns.normalexit0TERM#instance $indexscript# this script runs in /bin/sh by default# respawn as bash so we can source in rbenvexec/bin/bash<<'EOT' # Pick your poison :) Or none if you're using a system wide installed Ruby. # rbenv # source /home/apps/.bash_profile # OR # source /home/apps/.profile # OR system: # source /etc/profile.d/rbenv.sh # # rvm # source /home/apps/.rvm/scripts/rvm # Logs out to /var/log/upstart/sidekiq.log by default # 服务器上的数据库用户名和密码在这个文件里面 source /etc/environment # 服务器用的是 rbenv export HOME=/home/deploy export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH" cd /var/www/xxx_app/current exec bundle exec sidekiq -e production -P /var/www/xxx_app/current/tmp/pids/sidekiq.pid -L /var/www/xxx_app/current/log/sidekiq.logEOTendscript
monit 配置
monit 使用 upstart 的配置将会非常简单
/etc/monit/conf.d/sidekiq.monitrc
12345
check process sidekiq_application_production with pidfile /var/www/xxx_app/shared/tmp/pids/sidekiq.pid
start program="/bin/bash -c 'sudo start sidekiq'" stop program="/bin/bash -c 'sudo stop sidekiq'" with timeout 90 seconds
if totalmem is greater than 500 MB for2 cycles then restart # eating up memory? group sidekiq