Score:0

Monit restart process behavior

om flag
Ror

Monit's documentation states the following for the restart action :

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.

I'm monitoring some processes and I recently found out that the stop method is not called even though the restart method is not set. Here's the configuration :

check process myProcess matching "myProcess"
    start program = "/etc/init.d/myProcess start"
    stop program = "/etc/init.d/myProcess stop"
    if not exist then restart

It crashed yesterday and the log said :

[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 ... //The output of the init.d script. The process does not start since the PID file was not deleted by the stop method
[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 ...

Monit calls the start method which fails since the init.d script looks for the PID file that wasn't deleted since the process crashed. However, according to the documentation, Monit should first call the stop method (which in my case would delete de PID file) and then call the start method.

Is there a way to have this behavior in Monit or should I modify all my init.d scripts ?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.