summaryrefslogtreecommitdiff
path: root/devel/p5-Java/files/javaserver.in
blob: 4966e80499c036406860985b7d79ebb52da47430 (plain)
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
#!/bin/sh

# PROVIDE: javaserver
# REQUIRE: NETWORKING SERVERS
# BEFORE: DAEMON
# KEYWORD: shutdown

#
# Add the following lines to /etc/rc.conf to enable javaserver:
# javaserver_enable (bool):      Set to "NO" by default.
#                             Set it to "YES" to enable apache22
# javaserver_classpath (str):    Set to "" by default.
#                              Define your classpath here.
# javaserver_user (str):    Set to "nobody" by default.
#                              Define owner of the javaserver process.

. /etc/rc.subr

name="javaserver"
rcvar=javaserver_enable

load_rc_config $name

start_cmd="${name}_start"
stop_cmd="${name}_stop"
pidfile="/var/run/${name}.pid"
classpath="%%PREFIX%%"/share/p5-Java/JavaServer.jar

[ -z "$javaserver_classpath" ]	|| classpath="${javaserver_classpath}":$classpath
[ -z "$javaserver_enable" ]	&& javaserver_enable="NO"
[ -z "$javaserver_user" ]	&& javaserver_user="nobody"

javaserver_start()
{
	su -m ${javaserver_user} -c "nohup %%PREFIX%%/bin/java -cp ${classpath} com.zzo.javaserver.JavaServer >/dev/null & ; echo \$! " | tail -1 > ${pidfile}
}

javaserver_stop()
{
	if [ -f ${pidfile} ]; then
		rc_pid=`cat ${pidfile}`
		kill -TERM $rc_pid
		wait_for_pids $rc_pid
		rm ${pidfile}
	fi
}

run_rc_command "$1"