2012-11-17 59 views
6

我正在尝试为Sidekiq设置Monit。这里是我到目前为止我的配置文件:Monit Ruby on Rails Sidekiq

check process sidekiq_site 
    with pidfile /var/www/site/tmp/pids/sidekiq.pid 
    start program = "bundle exec sidekiq -C /var/www/site/config/sidekiq.yml -P /var/www/site/tmp/pids/sidekiq.pid" with timeout 90 seconds 
    if totalmem is greater than 200 MB for 2 cycles then restart # eating up memory? 
    group site_sidekiq 

的问题是我得到的消息,当我运行的monit重新加载程序“捆绑”不存在。

有没有人有解决方案?

+2

尽量写全路径打捆,像'/usr/local/lib/ruby/gems/1.9/ gem/bundler-1.2.3/bin/bundle“,甚至在路径前加上ruby路径。使用命令'哪个包'来查找完整路径。 – taro

回答

1

这是一个要点我在GitHub上写道:

check process sidekiq_production with pidfile /var/run/sidekiq_production.pid 
     depends on redis-server 
     start program = "/etc/init.d/sidekiq_production start" with timeout 90 seconds 
     stop program = "/etc/init.d/sidekiq_production stop" with timeout 90 seconds 
     if totalmem is greater than 200 MB for 2 cycles then restart # eating up memory? 
     if 2 restarts within 3 cycles then timeout 

我也写了一个init脚本sidekiq在Debian:https://gist.github.com/alain75007/5517948

4

上工作后,我自己的monit和sidekiq配置,我可以分享运行ubuntu的工作。

首先,如果你使用的是发行版,那么ubuntu会有一个sidekiq upstart脚本。有用于sidekiq和管理工作人员的脚本:https://github.com/mperham/sidekiq/tree/master/examples/upstart/manage-one

我遇到了一些错误与默认暴发户脚本,因为我使用rvm。检查/var/logs/upstart/sidekiq-0.log可以发现一些问题。 这条线:

exec bin/sidekiq -i ${index} -e production -C config/sidekiq.yml -P tmp/pids/sidekiq-${index}.pid

需要改为exec bundle exec sidekiq +选项

然后,对于符合我RVM藏在心里安装,我改变了以下内容:

#source $HOME/.rvm/scripts/rvm 
source /usr/local/rvm/scripts/rvm 

在/ etc/monit/monitrc中我引用了新贵脚本并且有:

# sidekiq 
check process sidekiq 
    with pidfile /var/www/apps/myapp/current/tmp/pids/sidekiq-0.pid 
    start program = "/usr/bin/sudo start sidekiq index=0" 
    stop program = "/usr/bin/sudo stop sidekiq index=0" 
    if totalmem is greater than 500 MB for 2 cycles then restart # eating up memory? 
    if 3 restarts within 5 cycles then timeout 
0

您的问题是缺少命令包。 我觉得你应该写这样的monit的配置文件:

check process sidekiq 
    with pidfile /srv/www/projects/myapp/shared/log/production.sidekiq.pid 
    start program = "/usr/bin/env /usr/bin/env HOME=/home/USER_NAME RACK_ENV=production RAILS_ENV=production PATH=/usr/local/bin:/usr/local/ruby/bin:/usr/bin:/bin:$PATH /bin/sh -l -c 'cd /srv/www/rails/myapp/current; bundle exec sidekiq'" as uid USER_NAME 
    stop program = "/usr/bin/env /usr/bin/env HOME=/home/USER_NAME RACK_ENV=production RAILS_ENV=production PATH=/usr/local/bin:/usr/local/ruby/bin:/usr/bin:/bin:$PATH /bin/sh -l -c 'cd/
    group myapp_workers 

如果你走进的应用程序目录中并捆绑,我认为它的工作。

0

下面是与RVM

check process sidekiq-th with pidfile /web/vcms/tmp/pids/sidekiq.pid 
    start program = "/home/dimon/.rvm/bin/rvm-shell -c '/web/vcms/sidekiq.sh start'" 
    stop program = "/bin/bash /web/vcms/sidekiq.sh stop &" 

它采用了script在Ubuntu工程的配置,主要线路是

开始

cd /web/vcms; sidekiq -d -e production & 

,并停止

sidekiqctl stop $PIDFILE 

我不是一个shell脚本大师和将感谢任何意见=)

1

最后这个解决方案为我般的魅力:)

check process sidekiq with pidfile path_to_my_pid_file/sidekiq.pid 

start program = "/bin/bash -c 'cd my_app_current && source /home/myuser/.rvm/environments/[email protected] && bundle exec sidekiq -e production -P path_to_my_pid_file/sidekiq.pid -L /my_shared_folder_path/log/sidekiq.log -C my_app_current/config/sidekiq.yml --daemon'" as uid "myuser" and gid "myuser" 

stop program = "/bin/bash -c 'kill -s INT `cat path_to_my_pid_file/sidekiq.pid`'" as uid "myuser" and gid "myuser" 

**请注意以下几点几点:**

  • 我使用RVM红宝石版本管理请rbenv检查。
  • 在这里,你需要通过红宝石的全局位置的方式,我通过在这里: - /home/myuser/.rvm/environments/[email protected]