- edited description
Stop a program first when process does not exist
Issue #1013
resolved
I am monitoring multiple process with “matching” like so :
check process myProcess matching "myProcess"
start program = "/etc/init.d/myProcess start"
stop program = "/etc/init.d/myProcess stop"
if not exist then restart
The documentation states the following :
RESTART restarts the service and send an alert. Restart is performed by calling the service's registered restart method or by first calling the stop method followed by the start method if restart is not set.
however, the process is only started if it is not running :
[CET Nov 9 12:30:36] error : 'myProcess' process is not running
[CET Nov 9 12:30:36] info : 'myProcess' trying to restart
[CET Nov 9 12:30:36] info : 'myProcess' start: '/etc/init.d/myProcess start'
[CET Nov 9 12:30:36] debug : Starting myProcess ...
myProcess is already running ...
[CET Nov 9 12:31:06] error : 'myProcess' failed to start (exit status 0) -- '/etc/init.d/myProcess start': Starting myProcess ...
myProcess is already running ...
I need monit to stop the service first to remove the PID file of the process. Is there a way to do this ?
Comments (4)
-
reporter -
repo owner -
assigned issue to
-
assigned issue to
-
repo owner I think the following should work:
check process myProcess matching "myProcess" start program = "/etc/init.d/myProcess start" stop program = "/etc/init.d/myProcess stop" restart program = "/bin/bash -c '/etc/init.d/myProcess stop && /etc/init.d/myProcess start" if not exist then restart
-
reporter - changed status to resolved
Thanks it works like a charm, I just changed this line because it was missing a ' :
restart program = "/bin/bash -c '/etc/init.d/myProcess stop && /etc/init.d/myProcess start'"
- Log in to comment