3

I am using monit to monitor several process. These process include passenger instances and a daemon I wrote to generate pidfiles for the passenger instance. Monit will start these process no problem. It will not stop them. The following is the Monit config for the daemon:

check process passenger_monitor with pidfile <%= passenger_monitor_pid %>
   group <%= application %>
   start program = "/bin/su - rails_apps -c 'source /home/rails_apps/.rvm/scripts/rvm; /home/rails_apps/passenger_monitor.rb'"
   stop program = "/bin/kill `/bin/cat <%= passenger_monitor_pid %>`"

It is a erb template that is generated via capistrano. If I run the stop command via a terminal as root with a minimal environment then it works, but when I request that Monit stops the process i get the following error:

[ADT Sep 17 10:38:31] error    : 'passenger_monitor' failed to stop

I have tried everything I can think of. I cannot find or generate any logs of the output of the stop command.

Charlie Greene
  • 465
  • 4
  • 11

1 Answers1

22

I have the same issue when trying to stop a service using

stop program = "/bin/kill `/bin/cat /var/run/pusher.pid`"

You can turn on the -Iv flag to see the debug output:

monit -Iv

Or you can manually validate while monit is running in the background:

monit validate

They both show

'api-pusher-service' stop: /bin/kill
kill: can't find process "`/bin/cat"
kill: can't find process "/var/run/pusher.pid`"

This fixes the problem for me

stop program = "/bin/bash -c '/bin/kill `/bin/cat /var/run/pusher.pid`'"
Stephie
  • 3,135
  • 17
  • 22
Wei Wu
  • 236
  • 3
  • 3