[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Failing to restart a process
From: |
Martin Pala |
Subject: |
Re: Failing to restart a process |
Date: |
Tue, 28 May 2013 09:38:36 +0200 |
Hi,
there could be problem with two checks, restarting the same process: when the
"stream_restart" tries to restart the process, the "stream_reader" will detect
that the process is not running and will try to restart it too (since there is
no connection between these two tests). The restart should be either performed
via dependency chain, or exec action which will restart the service with
process check:
--8<--
check file stream_restart with path /var/www/example.com/tmp/stream_restart.txt
if changed timestamp then exec "/usr/bin/monit restart stream_reader"
--8<--
Another question is, whether the stop/start programs work at all. Monit runs
the programs in a sandbox and strips all environment variables (for security
reasons) - it sets only the spartan "PATH=/bin:/usr/bin:/sbin:/usr/sbin"
variable. If your script depends on some env. variable, it may fail when
executed by monit. To test it try: "monit stop stream_reader" and "monit start
stream_reader"
Regards,
Martin
On May 27, 2013, at 11:22 PM, Marc Cooper <address@hidden> wrote:
> Hi,
>
> Apologies for the repost. I posted this three weeks ago, but sadly
> didn't any replies. I still have the same issue, so would appreciate any
> thought or ideas that anyone has. Thanks.
>
> I have the following rules in monitrc:
>
> check process stream_reader with pidfile /var/www/example.com/stream.pid
> start program = "/sbin/start stream"
> stop program = "/sbin/stop stream"
>
> This works as expected.
>
> I would also like to restart this process automatically on completion of
> another task.
>
> To do this I tried the following rule to respond to touching a file:
>
> check file stream_restart with path
> /var/www/example.com/tmp/stream_restart.txt
> start program = "/sbin/start stream"
> stop program = "/sbin/stop stream"
> if changed timestamp then restart
>
> However, when the file is touched, the process fails to restart.
>
> Diagnostics show that monit identifies that the timestamp has changed
> and tries to stop the process. However, the log shows that process
> shutdown enters its pre-stop phase, but never enters its post-stop
> phase. In other words, the process doesn't change.
>
> Is there a way to achieve the behaviour I require?
>
> Thanks,
> Marc
>
>
> Aside:
>
> If I change the second rule to stop the process:
>
> check file stream_restart with path
> /var/www/example.com/tmp/stream_restart.txt
> stop program = "/sbin/stop stream"
> if changed timestamp then stop
>
> Then the process stops and the first rule restarts the process. However,
> the second rule is then left in "Not monitored" mode by monit, so
> monitoring then needs to be reactivated manually, which is not viable.
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general