-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathempweb.sh
More file actions
300 lines (248 loc) · 8.26 KB
/
empweb.sh
File metadata and controls
300 lines (248 loc) · 8.26 KB
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#!/bin/sh
#
# Startup script for jetty under *nix systems (it works under NT/cygwin too).
#
# Configuration variables
#
# JAVA_HOME
# Home of Java installation.
#
# JAVA
# Command to invoke Java. If not set, $JAVA_HOME/bin/java will be used.
#
# JAVA_OPTIONS
# Extra options to pass to the JVM
#
# JETTY_HOME
# Where Jetty is installed.
# The java system property "jetty.home" will be
# set to this value for use by configure.xml files, f.e.:
#
# <Arg><SystemProperty name="jetty.home" default="."/>/webapps/jetty.war</Arg>
#
# JETTY_CONSOLE
# Where Jetty console output should go. Defaults to first writeable of
# /dev/console
# /dev/tty
#
#
# CISIS_LOCATION
# Folder where CISIS utilities could be accessed
#
# CISIS_COMMAND
# Command name for mx
#
# OS
# Operative System for mx wrapper
#
############################################################
####### EmpWeb environment variables and Java parameters.
####### CHANGE THIS TO CONFIGURE FOR YOUR LOCAL SETUP!
############################################################
# The root directory of the Empweb installation
EMPWEB_HOME="/opt/ABCD/empweb"
ABCD_URL="http://127.0.0.1:9090/"
OS="linux"
# Specify the Jetty configuration files for all the parts of Empweb that this server must run.
# If you want to run everything in one machine, then specify ewdbws, ewengine, ewgui configurations.
CONFIGS="$EMPWEB_HOME/common/etc/ewdbws-jetty.xml $EMPWEB_HOME/common/etc/ewengine-jetty.xml $EMPWEB_HOME/common/etc/ewgui-jetty.xml"
# Variables used by Jetty
JETTY_HOME="/opt/ABCD/empweb/jetty"
JETTY_START="$EMPWEB_HOME/common/etc/start.config"
JETTY_CONSOLE="$EMPWEB_HOME/logs/jetty-console.log"
# Java variables.
#JAVA_HOME="/usr/lib/jvm/jdk1.7.0_60/bin"
#JAVA_HOME="/opt/jdk1.8.0_181/bin"
#JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/bin"
#JAVA_HOME="/usr/lib/jvm/java-8-oracle/bin"
JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64/bin"
JAVA="$JAVA_HOME/java"
# CISIS Wrapper
CISIS_LOCATION="/opt/ABCD/www/cgi-bin/ansi/"
CISIS_COMMAND="mx"
OS=linux
# Logging settings.
LOGGING_CONF=$EMPWEB_HOME/common/etc/logging.properties
# For large memory machines, dedicated to Empweb, -Xms = initial heap size, -Xmx = maximum heap size
#JAVA_OPTIONS="-server -DSTART=$JETTY_START -Djetty.home=$JETTY_HOME -Dempweb.home=$EMPWEB_HOME -Djava.util.logging.config.file=$LOGGING_CONF -Daxis.xml.reuseParsers=true -Xms128M -Xmx512M"
#-Xincgc
# Or use less memory in smaller machines running other programs
# JAVA_OPTIONS="-server -DSTART=$JETTY_START -Djetty.home=$JETTY_HOME -Dempweb.home=$EMPWEB_HOME -Djava.util.logging.config.file=$LOGGING_CONF -Daxis.xml.reuseParsers=true -Xms64M -Xmx192M"
# Or let its inner strength decide:
JAVA_OPTIONS="-server -DSTART=$JETTY_START -Djetty.home=$JETTY_HOME -Dempweb.home=$EMPWEB_HOME -Djava.util.logging.config.file=$LOGGING_CONF -Daxis.xml.reuseParsers=true -Dsun.net.client.defaultConnectTimeout=10000 -Dcisis.location=$CISIS_LOCATION -Dcisis.command=$CISIS_COMMAND -Dabcd.url=$ABCD_URL -Dcisis.platform=$OS -Xms128M -Xmx128M"
############################################################################
#### You shouldn't change anything below unless you know what you're doing!
############################################################################
usage()
{
echo "Usage: $0 {start|startdebug|stop|check|supervise} [ CONFIGS ... ] "
exit 1
}
[ $# -gt 0 ] || usage
##################################################
# Find directory function
##################################################
findDirectory()
{
OP=$1
shift
for L in $* ; do
[ $OP $L ] || continue
echo $L
break
done
}
##################################################
# Get the action & configs
##################################################
ACTION=$1
shift
ARGS="$*"
###########################################################
# Get the list of config.xml files from the command line.
###########################################################
if [ ! -z "$ARGS" ]
then
for A in $ARGS
do
if [ -f $A ]
then
CONF="$A"
elif [ -f $JETTY_HOME/etc/$A ]
then
CONF="$JETTY_HOME/etc/$A"
elif [ -f ${A}.xml ]
then
CONF="${A}.xml"
elif [ -f $JETTY_HOME/etc/${A}.xml ]
then
CONF="$JETTY_HOME/etc/${A}.xml"
else
echo "** ERROR: Cannot find configuration '$A' specified in the command line."
exit 1
fi
if [ ! -r $CONF ]
then
echo "** ERROR: Cannot read configuration '$A' specified in the command line."
exit 1
fi
CONFIGS="$CONFIGS $CONF"
done
fi
#####################################################
# Find a location for the pid file
#####################################################
if [ -z "$JETTY_RUN" ]
then
JETTY_RUN=`findDirectory -w $EMPWEB_HOME /var/run /usr/var/run /tmp`
fi
#####################################################
# Find a PID for the pid file
#####################################################
if [ -z "$JETTY_PID" ]
then
JETTY_PID="$JETTY_RUN/jetty-devel.pid"
fi
#####################################################
# Find a location for the jetty console
#####################################################
if [ -z "$JETTY_CONSOLE" ]
then
if [ -w /dev/console ]
then
JETTY_CONSOLE=/dev/console
else
JETTY_CONSOLE=/dev/tty
fi
fi
#####################################################
# See if JETTY_PORT is defined
#####################################################
if [ "$JETTY_PORT" != "" ]
then
JAVA_OPTIONS="$JAVA_OPTIONS -Djetty.port=$JETTY_PORT "
fi
#####################################################
# Add jetty properties to Java VM options.
#####################################################
JAVA_OPTIONS="$JAVA_OPTIONS -Djetty.home=$JETTY_HOME -Djava.library.path=$EMPWEB_HOME/common/ext -Dfile.encoding=ISO8859_1"
#if [ "$ACTION" == "startdebug" ]
#if ["$ACTION" == "startdebug"]
#then
# JAVA_OPTIONS=" -DDEBUG $JAVA_OPTIONS "
#fi
#####################################################
# This is how the Jetty server will be started
#####################################################
RUN_CMD="$JAVA $JAVA_OPTIONS -jar $JETTY_HOME/"start.jar" $CONFIGS"
#####################################################
# Comment these out after you're happy with what
# the script is doing.
#####################################################
echo "JETTY_HOME = $JETTY_HOME"
echo "JETTY_RUN = $JETTY_RUN"
echo "JETTY_PID = $JETTY_PID"
echo "JETTY_CONSOLE = $JETTY_CONSOLE"
echo "CONFIGS = $CONFIGS"
echo "JAVA_OPTIONS = $JAVA_OPTIONS"
echo "JAVA = $JAVA"
echo "CLASSPATH = $CLASSPATH"
echo "RUN_CMD = $RUN_CMD"
#################################################
# Do the action
##################################################
case "$ACTION" in
start|startdebug)
echo "Starting Jetty: "
#if [ -f $JETTY_PID ]
#then
# echo "Already Running!!"
# exit 1
#fi
echo "STARTED Jetty `date`" >> $JETTY_CONSOLE
nohup sh -c "exec $RUN_CMD >>$JETTY_CONSOLE 2>&1" >/dev/null &
echo $! > $JETTY_PID
echo "Jetty running pid="`cat $JETTY_PID`
;;
stop)
PID=`cat $JETTY_PID 2>/dev/null`
echo "Shutting down Jetty: $PID"
kill $PID 2>/dev/null
sleep 2
kill -9 $PID 2>/dev/null
rm -f $JETTY_PID
echo "STOPPED `date`" >>$JETTY_CONSOLE
;;
supervise)
#
# Under control of daemontools supervise monitor which
# handles restarts and shutdowns via the svc program.
#
exec $RUN_CMD
;;
check)
echo "Checking arguments to Jetty: "
echo "JETTY_HOME = $JETTY_HOME"
echo "JETTY_RUN = $JETTY_RUN"
echo "JETTY_PID = $JETTY_PID"
echo "JETTY_CONSOLE = $JETTY_CONSOLE"
echo "JETTY_PORT = $JETTY_PORT"
echo "CONFIGS = $CONFIGS"
echo "PATH_SEPARATOR = $PATH_SEPARATOR"
echo "JAVA_OPTIONS = $JAVA_OPTIONS"
echo "JAVA = $JAVA"
echo "CLASSPATH = $CLASSPATH"
echo "RUN_CMD = $RUN_CMD"
echo
if [ -f $JETTY_RUN/jetty.pid ]
then
echo "Jetty running pid="`cat $JETTY_RUN/jetty.pid`
exit 0
fi
exit 1
;;
*)
usage
;;
esac
exit 0