Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Start and stop monit as deploy user

Jan Paul Posma edited this page May 15, 2014 · 1 revision

Starting and stopping a service using Capistrano and Monit can be quite cumbersome.

Define the Capistrano task like this:

  task :start_resque do
    run "sudo /usr/sbin/monit start resque"
  end

As you can see, the sudo command is used. We are deploying with Capistrano as the 'deploy' user, so we need to allow him to sudo the monit command.

To do that, add the following line to /etc/sudoers.d/users:

deploy   ALL = NOPASSWD: /usr/sbin/monit start resque, /usr/sbin/monit stop resque 

This states that the deploy user does not have to enter the sudo password for the commands defined after NOPASSWD: