[solved] ways to keep program running

This forum is for Marvell Kirkwood devices such as the GoFlex Home/Net, PogoPlug v1/v2, SheevaPlug, and ZyXEL devices.

[solved] ways to keep program running

Postby permitivity » Sat Jan 18, 2014 11:45 pm

Hello,
So I've had this audio monitor to listen in on the baby room. It's a pogoplug with a USB webcam attached to it, and uses ffmpeg to stream the audio from the USB webcam to another Pogoplug which runs ffmpeg to play the audio. It works great most of the time. Out of a few days, I get a couple of times when ffmpeg stops running for some reason. I kind of bandaid the issue by creating a cron job to do "systemctl stop babymonitor.service" and then "systemctl start babymonitor.service" every hour. It works ok, but sometimes one of them crashes and it stops working until the next time the cron job runs at the top of the hour.

Is there a better way to do this? Can I have a cron job run every 2 minutes and look to see whether or not the ffmpeg process is running?

Here's the "systemctl status" output when things stop working. I don't know if this help anyone?

baby monitor in the baby room:
$this->bbcode_second_pass_quote('', '
')[root@alarm ~]# systemctl status baby.service
baby.service - baby monitor
Loaded: loaded (/etc/systemd/system/baby.service; enabled)
Active: failed (Result: exit-code) since Sat 2014-01-18 05:17:43 CST; 23min ago
Process: 5252 ExecStart=/usr/bin/ffmpeg -re -f alsa -i plughw:0 -acodec mp2 -ab 128000 -ar 48000 -ac 1 -filter bandpass=f=600:csg=0:width_type=q:w=.806 -f rtp rtp://224.1.2.3:1234 (code=exited, status=1/FAILURE)
Main PID: 5252 (code=exited, status=1/FAILURE)



Here's the speaker portion:
$this->bbcode_second_pass_quote('', '
')[root@alarm ~]# systemctl status parent.service
parent.service - baby monitor
Loaded: loaded (/etc/systemd/system/parent.service; enabled)
Active: inactive (dead) since Sat 2014-01-18 05:17:53 CST; 14min ago
Process: 29259 ExecStart=/usr/bin/ffmpeg -i rtp://224.1.2.3:1234 -f alsa plughw:1 (code=exited, status=0/SUCCESS)
Process: 29256 ExecStartPre=/bin/sleep 45 (code=exited, status=0/SUCCESS)
Main PID: 29259 (code=exited, status=0/SUCCESS)


You can see how I'm forming the ffmpeg command on the baby portion as well as the parent portion of the service. If I'm doing something wrong, please let me know. Ideally, I'd like to find the root cause of these crashes, but it also makes me feel better if there's a better cron job that more frequently looks to see if the monitors are working. My current method is kind of blunt - just stopping and starting the services every hour.
Last edited by permitivity on Thu Jan 23, 2014 6:27 am, edited 1 time in total.
permitivity
 
Posts: 141
Joined: Mon Feb 18, 2013 3:08 am

Re: ways to keep program running

Postby moonman » Sun Jan 19, 2014 12:39 am

You could add Restart = always to the service file
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3388
Joined: Sat Jan 15, 2011 3:36 am

Re: ways to keep program running

Postby permitivity » Mon Jan 20, 2014 12:13 am

$this->bbcode_second_pass_quote('moonman', 'Y')ou could add Restart = always to the service file


Thanks for the tip.

I'm a noob when it comes to service file, and I don't really understand the different paragraphs in it. Can you elaborate where the restart command goes? Is it like this?

$this->bbcode_second_pass_quote('', '
')[Unit]
Description=baby monitor
After=network.target

[Service]
ExecStart=/usr/bin/ffmpeg -re -f alsa -i plughw:0 -acodec mp2 -ab 128000 -ar 48$
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

permitivity
 
Posts: 141
Joined: Mon Feb 18, 2013 3:08 am
Top

Re: ways to keep program running

Postby WarheadsSE » Mon Jan 20, 2014 1:28 am

Core Developer
Remember: Arch Linux ARM is entirely community donation supported!
WarheadsSE
Developer
 
Posts: 6807
Joined: Mon Oct 18, 2010 2:12 pm

Re: ways to keep program running

Postby permitivity » Thu Jan 23, 2014 6:27 am

The restart parameter works really well. Thanks.
permitivity
 
Posts: 141
Joined: Mon Feb 18, 2013 3:08 am


Return to Marvell Kirkwood

Who is online

Users browsing this forum: No registered users and 9 guests