forked from nickethier/fluxcapacitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-middletier
executable file
·94 lines (81 loc) · 2.24 KB
/
start-middletier
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
#!/bin/sh
if [ "x$FLUX_INCLUDE" = "x" ]; then
for include in "`dirname $0`/flux.in.sh"; do
if [ -r "$include" ]; then
. "$include"
break
fi
done
elif [ -r "$FLUX_INCLUDE" ]; then
. "$FLUX_INCLUDE"
fi
# Use JAVA_HOME if set, otherwise look for java in PATH
if [ -n "$JAVA_HOME" ]; then
JAVA="$JAVA_HOME/bin/java"
else
JAVA=java
fi
#JMX
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=9999"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
JVM_OPTS="$JVM_OPTS -Darchaius.deployment.applicationId=middletier"
JVM_OPTS="$JVM_OPTS -Darchaius.deployment.environment=$APP_ENV"
launch_service()
{
pidpath=$1
foreground=$2
props=$3
class=$4
flux_parms=""
if [ "x$pidpath" != "x" ]; then
flux_parms="$flux_parms -Dflux-pidfile=$pidpath"
fi
# The flux-foreground option will tell script not to close stdout/stderr, but it's up to us not to background.
if [ "x$foreground" != "x" ]; then
flux_parms="$flux_parms -Dflux-foreground=yes -Dlog4j.configuration=log4j-middle.properties"
exec "$JAVA" $JVM_OPTS $flux_parms -cp "$CLASSPATH" $props "$class"
# Startup fluxDaemon, background it, and write the pid.
else
exec "$JAVA" $JVM_OPTS $flux_parms -cp "$CLASSPATH" $props "$class" <&- &
[ ! -z "$pidpath" ] && printf "%d" $! > "$pidpath"
true
fi
return $?
}
# Parse any command line options.
args=`getopt vfhp:bD: "$@"`
eval set -- "$args"
classname="com.fluxcapacitor.middletier.server.MiddleTierServer"
while true; do
case "$1" in
-p)
pidfile="$2"
shift 2
;;
-f)
foreground="yes"
shift
;;
-h)
echo "Usage: $0 [-f] [-h] [-p pidfile]"
exit 0
;;
-D)
properties="$properties -D$2"
shift 2
;;
--)
shift
break
;;
*)
echo "Error parsing arguments!" >&2
exit 1
;;
esac
done
# Start up the service
launch_service "$pidfile" "$foreground" "$properties" "$classname"
exit $?
# vi:ai sw=4 ts=4 tw=0 et