質問

I'm using monit for monitoring my rails app. This is my monit.rb file:

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

When I run cap monit:setup on the end of log when monit go to reload I get:

** [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

failed: "sh -c 'sudo -p '\''sudo password: '\'' service monit reload'" on 11.111.1.11

Where is my error?

役に立ちましたか?

解決

The monit service daemon does not have a reload command argument. You can see the hint of the error here:

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

So you have to choose one of the above arguments. reload does not exist.
You probably want force-reload or restart instead.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top