![Monit 无法在 Opsworks 服务器上启动 sidekiq](https://linux22.com/image/619581/Monit%20%E6%97%A0%E6%B3%95%E5%9C%A8%20Opsworks%20%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E5%90%AF%E5%8A%A8%20sidekiq.png)
我使用 AWS Opsworks 创建了一些服务器。我将 Sidekiq 作为 Rails 应用程序的一部分运行。当我部署 Sidekiq 时,它会顺利重新启动。
我正在配置 Monit 来监视 pid,并在出现任何问题时启动和停止 Sidekiq。但是,当 Monit 尝试启动 Sidekiq 时,我发现似乎使用了错误的 Ruby。
Oct 17 13:52:43 daitengu sidekiq: /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/lib/bundler/definition.rb:361:in `validate_ruby!': Your Ruby version is 1.8.7, but your Gemfile specified 1.9.3 (Bundler::RubyVersionMismatch)
Oct 17 13:52:43 daitengu sidekiq: from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/lib/bundler.rb:116:in `setup'
Oct 17 13:52:43 daitengu sidekiq: from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/lib/bundler/setup.rb:17
当我从 cli 运行命令时,Sidekiq 正确启动。
$> cd /srv/www/myapp/current && RAILS_ENV=production nohup /usr/local/bin/bundle exec sidekiq -C config/sidekiq.yml >> /srv/www/myapp/shared/log/sidekiq.log 2>&1 &
$> ps -aef |grep sidekiq
root 1236 1235 8 20:54 pts/0 00:00:50 sidekiq 2.11.0 myapp [0 of 25 busy]
我的 sidekiq.monitrc 文件
check process unicorn with pidfile /srv/www/myapp/shared/pids/unicorn.pid
start program = "/bin/bash -c 'cd /srv/www/myapp/current && /usr/local/bin/bundle exec unicorn_rails --env production --daemonize -c /srv/www/myapp/shared/config/unicorn.conf'"
stop program = "/bin/bash -c 'kill -QUIT `cat /srv/www/myapp/shared/pids/unicorn.pid`'"