6

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

 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 reload 程序“捆绑”不存在时,我收到一条消息。

有人对此有解决方案吗?

4

6 回答 6

5

在完成我自己的 monit 和 sidekiq 配置之后,我可以分享对我运行 ubuntu 有用的东西。

首先,如果您在该发行版上,则存在一个用于 ubuntu 的 sidekiq upstart 脚本。有用于 sidekiq 和管理工作人员的脚本:https ://github.com/mperham/sidekiq/tree/master/examples/upstart/manage-one

当我使用 rvm 时,我在使用默认的 upstart 脚本时遇到了一些错误。检查 /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
于 2013-08-09T01:35:40.057 回答
4

检查:https ://groups.google.com/forum/?fromgroups= #!topic/rubyversionmanager/0abB9jlqi_Y 如果您使用 rvm,

/bin/su - <username> -c 'bundle exec sidekiq -C /var/www/site/config/sidekiq.yml -P /var/www/site/tmp/pids/sidekiq.pid'

如果从用户启动监视器,请在 .bash_profile 中设置 $HOME。

或调查 whis 答案:https ://github.com/mperham/sidekiq/issues/506

于 2012-11-29T08:27:26.313 回答
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

我还在 Debian 上为 sidekiq 编写了一个初始化脚本:https ://gist.github.com/alain75007/5517948

于 2013-05-04T16:36:43.123 回答
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/ruby-2.1.2@global && 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 进行 ruby​​ 版本管理,请检查 rbenv。
  • 在这里,您需要按照我在这里传递的方式传递 ruby​​ 的全局位置:-/home/myuser/.rvm/environments/ruby-2.1.2@global
于 2015-09-29T09:29:30.893 回答
0

这是在带有 rvm 的 Ubuntu 上工作的配置

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 &"   

它使用脚本,主要行是

开始

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

并停止

sidekiqctl stop $PIDFILE

我不是 shell 脚本专家,如果您有任何建议,我将不胜感激 =)

于 2015-04-16T10:57:19.757 回答
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

如果您走进应用程序目录并调用 bundle,我认为它可以工作。

于 2014-02-13T09:38:55.847 回答