thankyou martin I think I've cracked it now (the hard way)
monit appeared to be interested only in '/etc/init.d/<whatever> start' so I
created the script /etc/init.d/stream and the command '/etc/init.d/stream
start' worked. I now have monit working and auto-restarting the ffmpeg
process when it (often) goes down. Now I just have to tweak it so monit
checks the process more than once a minute.


On Wed, May 7, 2014 at 3:57 PM, Martin Pala <[email protected]> wrote:

> Alternatively you can monitor the process using pattern (no pidfile
> needed):
>
> check process myprocess matching "/usr/bin/myprocess -a -b -c"
>
> Regards,
> Martin
>
>
>
> On 07 May 2014, at 13:34, Anthony Griffiths <[email protected]> wrote:
>
> I think I realise now what the (simple) problem is.
> monit does not line '/bin/sh /root/stream-start.sh', I need to use
> something else but I don't know what.
>
>
> On Wed, May 7, 2014 at 7:09 AM, Weedy <[email protected]> wrote:
>
>> On 06/05/14 06:03 PM, Anthony Griffiths wrote:
>> > I wrote a script called stream-start.sh that follows your instructions
>> > but even though ffmpeg starts fine it does not create a pid file. I
>> > created this:
>> > *long-ffmpeg-command &*
>> > *pid=$!*
>> > *echo $pid > /var/run/stream.pid*
>> cat > /root/start-stream.sh
>> #!/bin/sh
>> if [ ! -d /var/run/ ]; then mkdir -p /var/run/; fi
>> if [ -f /var/run/stream.pid ]; then rm /var/run/stream.pid; fi
>>
>> /usr/bin/ffmpeg -a -lot -of -options &
>> sleep 3 # make sure it's given enough time to start/die??
>> echo $(pidof --single-shot ffmpeg) > /var/run/stream.pid
>>
>> <hit ctrl+d after at least one blank line>
>> chmod +x /root/start-stream.sh # not really needed
>> > but this didn't work and and after trawling google and trying a few
>> > variations the script still does not create a pid file.
>> >
>> > in monitrc I have:
>> > *check process stream with pidfile /var/run/stream.pid*
>> > *       start = "/usr/bin /root/start-stream.sh"*
>> > and monit starts without any complaints
>>
>> I... what? /usr/bin is a directory. This is probably why $! failed for
>> you, your not running the file with a specific interpreter. Hard code
>> the interpreter so this never happens again.
>>
>> start = "/bin/sh /root/start-stream.sh"
>>
>> --
>> To unsubscribe:
>> https://lists.nongnu.org/mailman/listinfo/monit-general
>>
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general
>
>
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general
>
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

Reply via email to