Tutorial : How to keep Wowza alive

I use wowza 3 for heavy vod system. 2 running as mediacaches server and sometime one of the server will die. If checked with WowzaMediaServer status, it will return started. So here’s my solution.

  1. Check the server status by using curl for example:
curl -I "http://localhost/vod/mp4:sample.mp4/chunklist.m3u8"
HTTP/1.1 200 OK
Date: Sat, 19 Jul 2014 02:46:03 GMT
Content-Type: application/vnd.apple.mpegurl
Server: FlashCom/3.5.7
Cache-Control: no-cache
Content-Length: 2828

What the information I need from curl is 1st return query “HTTP/1.1 200 OK”

So easily I can do simple programming using PHP to check the server health

location: /root/check_wowza.php

<?php
$url = "http://localhost:1935/vod/mp4:sample.mp4/chunklist.m3u8"; // default sample.mp4 wowza
$s = @get_headers($url);
if($s == FALSE ){
        //server down
        //echo 'down';
        system('/root/restart_wowza.sh');
} else {
        if($s[0] != 'HTTP/1.0 200 OK'){
                system('/root/restart_wowza.sh');
        }
}

The script will check if the server alive or not. If not, it will trigger another script located at /root/restart_wowza.sh

#!/bin/bash
/usr/bin/killall java
sleep 5
/sbin/service WowzaMediaServer start

Make sure to chmod +x all scripts

now we can test the scripts by running via command line

/usr/bin/php -q /root/check_wowza.php

If it’s running perfectly, put into cron job and set it run for every 5 minutes, type crontab -e

*/5 * * * * /usr/bin/php -q /root/check_wowza.php

Hopefully this little snippets works for your needs…especially when you’re lone SystemAdmin with hundreds of servers :smiley:

worldofwarcraft


@botakchin | Human Alliance | Gundrak PVP

Hi,

It’s great to see the Wowza community sharing useful tips and code to help each other out.

Thank you so much for posting.

Regards,

Jason

thanks for sharing this helpful tutorial! :slight_smile: