Wowza Media Server on FreeBSD

Hello, Tell me, please, how to run the Wowza Media Server as daemon on FreeBSD 8? There are was no problems with the installation, using startup.sh it run normally, but “/path/to/WowzaMediaServer/bin/WowzaMediaServer start” does not work. How I can run it at startup and daemon mode?

It’s in the User Manual, I think it is:

/etc/init.d/WowzaMediaServer start

or

/sbin/service WowzaMediaServer start

Richard

Here is the script:

#!/bin/bash
#
# Startup script for Wowza Media Server
#
# chkconfig: - 80 20
# description: Wowza Media Server is a media server
#
#### BEGIN INIT INFO
# Provides:          WowzaMediaServer
# Required-Start:    $syslog $time $local_fs $remote_fs
# Required-Stop:     $syslog $time $local_fs $remote_fs
# Default-Start:     3 4 5
# Default-Stop:      S 0 1 2 6
# Short-Description: Wowza Media Server 2 Init Script
# Description:       Wowza Media Server 2 Init Script
### END INIT INFO
WMCOMMAND=${1}
FUNCTIONS_EXIST=false
if [ -f /etc/rc.d/init.d/functions ] ; then
     . /etc/rc.d/init.d/functions
     FUNCTIONS_EXIST=true
fi
if [ -f /etc/init.d/functions ] ; then
     . /etc/init.d/functions
     FUNCTIONS_EXIST=true
fi
if ! $FUNCTIONS_EXIST ; then
failure() {
  return 0
}
success() {
  return 0
}
fi
# define vars
RETVAL=0
WMSBASE_NAME=WowzaMediaServer
#WMSCONFIG_SCRIPT="/etc/WowzaMediaServer/$WMSBASE_NAME.conf"
WMSCONFIG_SCRIPT="/usr/local/WowzaMediaServer/bin/setenv.sh"
WMSLICENSE_FILE="/usr/local/WowzaMediaServer/conf/Server.license"
AMAZONEC2_INSTALL_SCRIPT="/usr/local/WowzaMediaServer/bin/AmazonEC2Install.sh"
WMSDAEMON_CMD=/usr/bin/WowzaMediaServerd
WMSPID_FILE="/var/run/$WMSBASE_NAME.pid"
WMSLOCK_FILE="/var/run/$WMSBASE_NAME"
SHUTDOWN_WAIT=20
[ -r "$WMSCONFIG_SCRIPT" ] && . "$WMSCONFIG_SCRIPT"
if ! test -f "${WMSLICENSE_FILE}" ; then
        echo ""
        echo "ERROR: Missing license file: (${WMSLICENSE_FILE})"
        echo "You must first run Wowza Media Server 2 in "
        echo "standalone mode to enter serial number. Execute the "
        echo "following commands to run in standalone mode:"
        echo ""
        echo "cd /usr/local/WowzaMediaServer"
        echo "./startup.sh"
        echo ""
        exit 0
fi
testjava=`which ${_EXECJAVA} 2>/dev/null`
if ! test -f "$testjava" ; then
	echo ""
	echo "ERROR: The Java command (${_EXECJAVA}) could not be found."
	echo "Search path: $PATH"
	echo "In most cases this problem can be fixed by adding a symbolic "
	echo "link to the Java command in the /usr/bin directory. "
	echo "To do this first execute the command \"which java\" to identify "
	echo "the full path to the Java executable. Next, create a symbolic "
	echo "link to this file with the command"
	echo "\"ln -sf [path-to-java] /usr/bin/java\" where [path-to-java] is "
	echo "the path returned by the \"which\" command."
	echo ""
	exit 0
fi
#
start() {
if [ -f $WMSPID_FILE ]; then
	read kpid < $WMSPID_FILE
	kill -9 $kpid
	echo $"$WMSBASE_NAME is already running ($kpid): stopping"
	rm -f $WMSPID_FILE
fi
echo -n $"$WMSBASE_NAME: starting"
#$AMAZONEC2_INSTALL_SCRIPT
$WMSDAEMON_CMD $WMSCONFIG_SCRIPT $WMSPID_FILE start >/dev/null 2>&1 &
success "$WMSBASE_NAME startup"
echo
touch $WMSLOCK_FILE
return 0
}
stop() {
if [ -f $WMSPID_FILE ]; then
	echo -n $"$WMSBASE_NAME: stopping"
	read kpid < $WMSPID_FILE
	$WMSDAEMON_CMD $WMSCONFIG_SCRIPT $WMSPID_FILE stop >/dev/null 2>&1 &
	let kwait=$SHUTDOWN_WAIT
	count=0;
	until [ `ps -p $kpid | grep -c $kpid` = '0' ] || [ $count -gt $kwait ]
	do
		echo -n -e "\nwaiting for processes to exit";
		sleep 1
		let count=$count+1;
	done
	if [ $count -gt $kwait ]; then
		echo -n -e "\nkilling processes which didn't stop after $SHUTDOWN_WAIT seconds"
		kill -9 $kpid
	fi
	rm -f $WMSPID_FILE
	success "$WMSBASE_NAME shutdown"
else
	echo -n $"$WMSBASE_NAME: not running"
fi
echo
rm -f $WMSLOCK_FILE
return 0
}
localstatus() {
if [ -f $WMSLOCK_FILE ]; then
	echo "$WMSBASE_NAME started"
else
	echo "$WMSBASE_NAME stopped"
fi
RETVAL=0
}
# See how we were called.
case "$WMCOMMAND" in
start)
start
;;
stop)
stop
;;
status)
localstatus
;;
restart)
stop
start
;;
*)
echo $"Usage: $WMSBASE_NAME {start|stop|restart|status}"
exit 1
esac
exit $RETVAL

Charlie

We have a few customers on FreeBSD but not a lot. One of our largest customers is on FreeBSD but they did their own customization. We have had folks report that Java is not always super stable on FreeBSD. So I guess the answer is that for some it works for some it does not. Linux, Solaris, Unix all work great!

Charlie

We have serveral customers running the latest, latest Java VM (I think it is a build in the udpate 20 range) without any issues. Be sure you get the latest, latest version.

Charlie

I search around and found this Try:

/etc/rc.d/WowzaMediaServer start

Richard

This error means Wowza is already running, or another service using port 1935 is running – Maybe FMIS or red5.

Richard

Should be able to use one of these:

/sbin/service WowzaMediaServer start
/etc/init.d/WowzaMediaServer start

Richard

This is true for Linux, not for FreeBSD. There are no such paths.

Yes, that’s right, thanks, I know it. The fact that rc script was not created during installation, I wrote it myself. Thank you for your answers, topic can be closed.

Hello, i try install in FreeBSD and have a problem

/usr/local/WowzaMediaServer/bin/>./start.sh

stop install

WARN vhost comment defaultVHost Bind failed, try again ([any]:1935): java.net.BindException: Address already in use

:confused:

Hi Guys

I am having the same problem, I have just installed WowzaMediaServer on a FreeBSD 8.1 server and confirmed it works with standalone mode.

But I need the rc script to start it as a demon at boot. Does anyone have a copy of this?

Also, in the mean time, is there a way to keep Wowza running in standalone mode without having to have an open command line session? ‘Screen’ does not work :frowning:

Thanks :slight_smile:

Thanks for the reply.

But these paths do not exist in FreeBSD and there is no ‘WowzaMediaServer’ rc script anywhere else after the install.

Thanks :slight_smile:

I am modifying it now, but as this is my first real exposure to an rc script, I am having some trouble: at the moment I need to find the FreeBSD equivalent of ‘/etc/rc.d/init.d/functions’ or ‘/etc/init.d/functions’. I assumed it would be ‘/etc/rc.d’ but that was a no go :frowning: I have also tries /etc/rc.subr, I added ‘WowzaMediaServer_enable=“YES”’ to the /etc/rc.conf but t still fails to start at boot.

I can see there was a binary in the FreeBSD ports directory for Version 1.7.9, and I can only assume that it was ported properly and contains the correct files and paths. Unfortunately, it is no longer available so I can not steal the ported scripts from there. I don’t suppose your devs would have these laying around?

Perhaps I am a bit frustrated at this point, but why is it that the installation guide only takes the Unix install upto running in standalone mode? Is it officially unsupported in Unix/FreeBSD or is there a chance this will be fixed? At this point I seem to be developing the FreeBSD script for you… and I am no developer in any stretch of the imagination lol

That’s just it though, aside from the rc script everything else works great. From what I can tell, it is only a matter of a few paths, I just don’t get why there isn’t a script provided.

At least I get to learn stuff :slight_smile:

Edit: Unfortunately, I have been unable to do this and the support team have decided that they are not interested in supporting a potential customer, losing a grand for what should be a simple task. Any other users hoping to use FreeBSD with Wowza should know that they will get no assistance, I can only expect this extends to other platforms. I have since found that there are other free options that come with proper support.

is wowza 2 now “stable” on freeBSD? i would love to install freebsd to all of my like 20 servers or so but ive read in the forum that java seems to be unstable ? Does it work with the diablo jdk? Anyone got it in production on freebsd and can tell me some numbers?

nice, thanks charlie.

then let the reinstalls begin! :wink:

I attached what I came up with. Works for me on 8.2 and 9.0-RC1.

#!/bin/sh
# PROVIDE: wowza
# REQUIRE: NETWORKING SERVERS
# BEFORE: DAEMON
# KEYWORD: shutdown
wowza_enable="${wowza_enable:-"NO"}"
wowza_flags="${wowza_flags:-""}"
wowza_home="${wowza_home:-"/usr/local/WowzaMediaServer"}"
wowza_user="${wowza_user:-"www"}"
wowza_stop_timeout="${wowza_stop_timeout:-"5"}"
wowza_config_home="${wowza_config_home:-"/usr/local/WowzaMediaServer"}"
wowza_config_url="${wowza_config_url:-""}"
wowza_java_opts="${wowza_java_opts:-"-Xmx1200M -server -Djava.net.preferIPv4Stack=true"}"
wowza_stdout_log="${wowza_stdout_log:-"/var/log/wowza.log"}"
wowza_stderr_log="${wowza_stderr_log:-"/var/log/wowza.err"}"
. /etc/rc.subr
name="wowza"
rcvar=`set_rcvar`
pidfile="/var/run/${name}.pid"
procname="/usr/local/diablo-jre1.6.0/bin/java"
required_files="${wowza_home}/conf/Server.license"
load_rc_config "${name}"
if [ -n "${wowza_java_home}" ] ; then
	export JAVA_HOME="${wowza_java_home}"
fi
if [ -n "${wowza_java_version}" ] ; then
	export JAVA_VERSION="${wowza_java_version}"
fi
if [ -n "${wowza_java_vendor}" ] ; then
	export JAVA_VENDOR="${wowza_java_vendor}"
fi
if [ -n "${wowza_java_os}" ] ; then
	export JAVA_OS="${wowza_java_os}"
fi
case ${wowza_jmxconsole_enable} in
	[Yy][Ee][Ss])
		wowza_java_opts="${wowza_java_opts} -Dcom.sun.management.jmxremote=true "
		;;
	*)
		;;
esac
start_precmd=touch_logs
touch_logs () {
	touch $wowza_stdout_log && chown $wowza_user $wowza_stdout_log
	touch $wowza_stderr_log && chown $wowza_user $wowza_stderr_log
}
java_command="/usr/local/bin/java ${wowza_java_opts} \
	-Dcom.wowza.wms.AppHome=${wowza_home} \
	-Dcom.wowza.wms.ConfigURL=${wowza_config_url} \
	-Dcom.wowza.wms.ConfigHome=${wowza_config_home} \
	-cp ${wowza_home}/bin/wms-bootstrap.jar com.wowza.wms.bootstrap.Bootstrap"
log_args=">> ${wowza_stdout_log} 2>> ${wowza_stderr_log} "
command="/usr/sbin/daemon"
command_args="-p ${pidfile} ${java_command} ${wowza_flags} $1 ${log_args}"
run_rc_command "$1"