Viktor,

I am afraid I don't understand what are you trying to say.

This line:
stop = "/bin/bash -c 'kill $MONIT_PROCESS_PID'"

Works perfectly fine. Correct PID gets exposed and the desired process is 
killed.
My question is what is executed if I omit the line completely and require monit 
to stop the process.

Muhamed Huseinbašić
________________________________
From: monit-general 
<[email protected]> on behalf of 
SZÉPE Viktor <[email protected]>
Sent: 30 January 2018 11:32
To: This is the general mailing list for monit
Subject: Re: What is the default stop action?

Idézem/Quoting Muhamed Huseinbašić <[email protected]>:

> Hi everyone.
>
> I am sorry if this exists in the docs, I couldn't find it anywhere.
>
> E.g.:
>
> check process rqworker1 matching "^/usr/bin/python.*/usr/local/bin/rqworker1"
>     start program = "/opt/startup/startstop.sh start rqworker1 owner
> /usr/bin/python /usr/local/bin/rqworker1 -c worker --name rqworker1"
>     stop = "/bin/bash -c 'kill $MONIT_PROCESS_PID'"
>
> I know (correct me if I am wrong) that monit in this case exports
> correct PID under MONIT_PROCESS_PID and I can do whatever I want in
> the "stop" part.
>
> Now, my question is what happens if I omit the "stop" part completely?
> I.e. what exactly will be executed when I do "monit stop rqworker1"?
> Is there some default stop command under the hood?


https://mmonit.com/monit/documentation/monit.html#ENVIRONMENT

> ... when Monit executes a start/stop/restart program ...

I think only the programs get these variables.
Try using a shell script.

cat <<"EOF" > /usr/local/sbin/monit-process-stop.sh
#!/bin/bash
kill "$MONIT_PROCESS_PID"
EOF
chmod +x /usr/local/sbin/monit-process-stop.sh

...and you may prepare the script for failed stopping or non-existent process.




SZÉPE Viktor, honlap üzemeltetés
https://github.com/szepeviktor/debian-server-tools/blob/master/CV.md
--
+36-20-4242498  [email protected]  skype: szepe.viktor
Budapest, III. kerület





--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
-- 
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

Reply via email to