blob: 9d66af8d4d0ef3da90893c422151b819ab868448 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: wowza
# REQUIRE: NETWORKING SERVERS
# BEFORE: DAEMON
# KEYWORD: shutdown
#
# Configuration settings for wowza in /etc/rc.conf:
#
# wowza_enable (bool):
# Set to "NO" by default.
# Set it to "YES" to enable wowza
#
# wowza_jmxconsole_enable (bool):
# Set to "YES" by default.
# Set it to "NO" to disable jmxconsole in wowza
#
# wowza_flags (str):
# Set to "" by default.
# Extra flags passed to start command
#
# wowza_home (str)
# Set to "/usr/local/WowzaMediaServerPro" by default.
# Defile application home for java process
#
# wowza_user (str)
# Set to "www" by default.
# Set the posix user for java process
#
# wowza_stop_timeout (num)
# Set to "10" by default.
# Sets the timeout in seconds to allow tomcat to shutdown.
# After the timeout has elapsed, tomcat will be killed.
#
# wowza_stdout_log (str)
# Set to "%%STDOUT_LOG%%" by default.
# Set the location for the java process log (standard output)
#
# wowza_stderr_log (str)
# Set to "%%STDERR_LOG%%" by default.
# Set the location for the java process log (error output)
#
# wowza_java_home (str):
# wowza_java_vendor (str):
# wowza_java_version (str):
# wowza_java_os (str):
# Specify the requirements of the Java VM to use. See javavm(1).
#
# wowza_java_opts (str):
# Set to "-Xmx768M" by default.
# Java VM args to use.
#
wowza_enable="${wowza_enable:-"NO"}"
wowza_jmxconsole_enable="${wowza_jmxconsole_enable:-"YES"}"
wowza_flags="${wowza_flags:-""}"
wowza_home="${wowza_home:-"/usr/local/WowzaMediaServerPro"}"
wowza_user="${wowza_user:-"www"}"
wowza_stop_timeout="${wowza_stop_timeout:-"10"}"
wowza_config_home="${wowza_config_home:-"/usr/local/WowzaMediaServerPro"}"
wowza_config_url="${wowza_config_url:-""}"
wowza_java_version="${wowza_java_version:-"%%JAVA_VERSION%%"}"
wowza_java_opts="${wowza_java_opts:-"-Xmx768M"}"
wowza_config_home="${wowza_config_home:-"/usr/local/WowzaMediaServerPro"}"
wowza_config_url="${wowza_config_url:-""}"
wowza_stdout_log="${wowza_stdout_log:-"%%STDOUT_LOG%%"}"
wowza_stderr_log="${wowza_stderr_log:-"%%STDERR_LOG%%"}"
. /etc/rc.subr
name="wowza"
rcvar=wowza_enable
pidfile="/var/run/${name}.pid"
procname="java"
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
java_command="%%LOCALBASE%%/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} "
required_files="${wowza_home}/conf/Server.license"
command="/usr/sbin/daemon"
flags="-p ${pidfile} ${java_command} start ${wowza_flags} ${log_args}"
start_precmd=pid_touch
stop_cmd="wowza_stop"
pid_touch ()
{
touch $pidfile
chown $wowza_user $pidfile
}
wowza_stop() {
rc_pid=$(check_pidfile $pidfile $procname)
if [ -z "$rc_pid" ]; then
[ -n "$rc_fast" ] && return 0
if [ -n "$pidfile" ]; then
echo "${name} not running? (check $pidfile)."
else
echo "${name} not running?"
fi
return 1
fi
echo "Stopping ${name}."
${java_command} stop
wowza_wait_max_for_pid ${wowza_stop_timeout} ${rc_pid}
kill -KILL ${rc_pid} 2> /dev/null && echo "Killed."
rm -f ${pidfile}
}
wowza_wait_max_for_pid() {
_timeout=$1
shift
_pid=$1
_prefix=
while [ $_timeout -gt 0 ] ; do
echo -n ${_prefix:-"Waiting (max $_timeout secs) for PIDS: "}$_pid
_prefix=", "
sleep 2
kill -0 $_pid 2> /dev/null || break
_timeout=$(($_timeout-2))
done
if [ -n "$_prefix" ]; then
echo "."
fi
}
run_rc_command "$1"
|