cap monit:设置失败

时间:2013-01-06 12:48:19

标签: ruby-on-rails ruby ruby-on-rails-3 monit

我正在使用monit来监控我的rails应用。这是我的 monit.rb 文件:

namespace :monit do
  desc "Install Monit"
  task :install do
    run "#{sudo} apt-get -y install monit"
  end
  after "deploy:install", "monit:install"

  desc "Setup all Monit configuration"
  task :setup do
    #monit_config "monitrc", "/etc/monit/monitrc"
    #nginx
    #unicorn
    monit_config "nginx"
    syntax
    reload
  end
  after "deploy:setup", "monit:setup"

  task(:nginx, roles: :web) { monit_config "nginx" }
  task(:unicorn, roles: :app) { monit_config "unicorn" }

  %w[start stop restart syntax reload].each do |command|
    desc "Run Monit #{command} script"
    task command do
      run "#{sudo} service monit #{command}"
    end
  end
end

def monit_config(name, destination = nil)
  destination ||= "/etc/monit/conf.d/#{name}.conf"
  template "monit/#{name}.erb", "/tmp/monit_#{name}"
  run "#{sudo} mv /tmp/monit_#{name} #{destination}"
  run "#{sudo} chown root #{destination}"
  run "#{sudo} chmod 600 #{destination}"
end

当我在monit上重新加载时,在日志结束时运行cap monit:setup我得到:

** [out :: 11.111.1.11] Control file syntax OK
    command finished in 1073ms
  * executing `monit:reload'
  * executing "sudo -p 'sudo password: ' service monit reload"
    servers: ["11.111.1.11"]
    [50.116.2.102] executing command
 ** [out :: 11.111.1.11] Usage: /etc/init.d/monit {start|stop|restart|force-reload|syntax}
    command finished in 987ms
failed: "sh -c 'sudo -p '\\''sudo password: '\\'' service monit reload'" on 11.111.1.11

失败:“sh -c'sud'-p'\''sudo密码:'\''服务monit reload'”11.111.1.11

我的错误在哪里?

1 个答案:

答案 0 :(得分:0)

monit服务守护程序没有reload命令参数。你可以在这里看到错误的提示:

Usage: /etc/init.d/monit {start|stop|restart|force-reload|syntax}

所以你必须选择上述参数之一。 reload不存在 您可能需要force-reloadrestart