[Freeswitch-users] safe_freeswitch (like safe_asterisk): restarting FS automatically?

John Skopis (Lists) jlists at skopis.com
Wed Jul 23 18:43:12 PDT 2008


Birgit Arkesteijn wrote:
> Hi all,
> 
> We've got an older version of FreeSWITCH (Trunk 7948) running on a Linux 
> x86_64 machine. At the moment it's crashing few times a day, making our 
> services very unreliable.
> 
> At the moment we don't have the time to rebuild this version, so I'm 
> looking for an equivalent of the "safe_asterisk" script. This script 
> runs Asterisk in a loop, restarting it when it goes down.
> 
> I couldn't find any equivalent script, but maybe I using the wrong 
> keywords in my search.
> 
> Does anyone know if such a script is available, and (if so) could you 
> point out where I can find it?
> 
> Thanks, Birgit
> 


not too go against the freeswitch crew, especially since I agree you 
should probably update. (just backup fs first).

I am not sure of the performance implications running fs like this (-nf) 
but you can do something like (and this it's quite a nasty hack):


#!/bin/sh

PREFIX=/usr/local/freeswitch

stop() {
	local count=0
	kill -9 `cat /var/run/freeswitch_loop.pid` > /dev/null 2>&1

	while [ $count -lt 10 ]; do
		[ $count -gt 0 ] && sleep 5
		count=`expr $count + 1`
		pidof freeswitch > /dev/null && killall freeswitch || count=100
	done

	return $?
}

start() {
	while true; do $PREFIX/bin/freeswitch -nc -nf > /dev/null 2>&1; done &
	echo $! > /var/run/freeswitch_loop.pid
	return 0
}

case "$1" in
	start) start ;;
	stop) stop ;;
	restart) killall -HUP freeswitch;;
	reload) killall -HUP freeswitch;;
	
esac

exit $?





More information about the FreeSWITCH-users mailing list