Skip to content

Commit ffe1d21

Browse files
committed
Moved GeoServer to background
* GeoServer will now start in the background and save the PID to data/geoserver/pid/geoserver.pid * GeoServer stdout is redirected to data/geoserver/log/std.out Signed-off-by: Austin Heyne <[email protected]>
1 parent 8e6882a commit ffe1d21

File tree

2 files changed

+51
-15
lines changed

2 files changed

+51
-15
lines changed

bin/cloud-local.sh

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# thanks accumulo for these resolutions snippets
44
# Start: Resolve Script Directory
55
SOURCE="${BASH_SOURCE[0]}"
6-
while [ -h "${SOURCE}" ]; do # resolve $SOURCE until the file is no longer a symlink
6+
while [[ -h "${SOURCE}" ]]; do # resolve $SOURCE until the file is no longer a symlink
77
bin="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
88
SOURCE="$(readlink "${SOURCE}")"
99
[[ "${SOURCE}" != /* ]] && SOURCE="${bin}/${SOURCE}" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
@@ -37,7 +37,7 @@ function download_packages() {
3737
test -d ${CLOUD_HOME}/pkg || mkdir ${CLOUD_HOME}/pkg
3838

3939
local mirror
40-
if [ -z ${pkg_src_mirror+x} ]; then
40+
if [[ -z ${pkg_src_mirror+x} ]]; then
4141
local mirror=$(curl 'https://www.apache.org/dyn/closer.cgi' | grep -o '<strong>[^<]*</strong>' | sed 's/<[^>]*>//g' | head -1)
4242
else
4343
local mirror=${pkg_src_mirror}
@@ -179,15 +179,22 @@ function start_first_time {
179179
sleep 5
180180

181181
# starting accumulo
182-
echo "starting accumulo..."
182+
echo "Starting accumulo..."
183183
$ACCUMULO_HOME/bin/start-all.sh
184184
fi
185185

186186
if [[ "$hbase_enable" -eq 1 ]]; then
187187
# start hbase
188-
echo "starting hbase..."
188+
echo "Starting hbase..."
189189
${HBASE_HOME}/bin/start-hbase.sh
190190
fi
191+
192+
# init GeoServer Support
193+
mkdir -p "${GEOSERVER_DATA_DIR}"
194+
mkdir "${GEOSERVER_PID_DIR}"
195+
mkdir "${GEOSERVER_LOG_DIR}"
196+
touch "${GEOSERVER_PID_DIR}/geoserver.pid"
197+
touch "${GEOSERVER_LOG_DIR}/std.out"
191198
}
192199

193200
function start_cloud {
@@ -213,16 +220,26 @@ function start_cloud {
213220
hdfs dfsadmin -safemode wait
214221

215222
if [[ "$acc_enable" -eq 1 ]]; then
216-
# starting accumulo
217-
echo "starting accumulo..."
223+
# Starting accumulo
224+
echo "Starting accumulo..."
218225
$ACCUMULO_HOME/bin/start-all.sh
219226
fi
220227

221228
if [[ "$hbase_enable" -eq 1 ]]; then
222229
# start hbase
223-
echo "starting hbase..."
230+
echo "Starting hbase..."
224231
${HBASE_HOME}/bin/start-hbase.sh
225232
fi
233+
234+
if [[ $GEOSERVER_ENABLED ]]; then
235+
echo "Starting GeoServer..."
236+
(${GEOSERVER_HOME}/bin/startup.sh &> ${GEOSERVER_LOG_DIR}/std.out) &
237+
GEOSERVER_PID=$!
238+
echo "${GEOSERVER_PID}" > ${GEOSERVER_PID_DIR}/geoserver.pid
239+
echo "GeoServer Process Started"
240+
echo "PID: ${GEOSERVER_PID}"
241+
echo "GeoServer Out: ${GEOSERVER_LOG_DIR}/std.out"
242+
fi
226243
}
227244

228245
function start_yarn {
@@ -253,6 +270,17 @@ function stop_cloud {
253270

254271
echo "Stopping zookeeper..."
255272
$ZOOKEEPER_HOME/bin/zkServer.sh stop
273+
274+
if [[ $GEOSERVER_ENABLED} ]]; then
275+
echo "Stopping GeoServer..."
276+
GEOSERVER_PID=`cat ${GEOSERVER_PID_DIR}/geoserver.pid`
277+
if [[ -n "${GEOSERVER_PID}" ]]; then
278+
kill -15 ${GEOSERVER_PID}
279+
echo "TERM signal sent to process PID:${GEOSERVER_PID}"
280+
else
281+
echo "No GeoServer PID was saved. This script must be used to start GeoServer in order for this script to be able to stop it."
282+
fi
283+
fi
256284
}
257285

258286
function stop_yarn {
@@ -268,7 +296,7 @@ function clear_sw {
268296
rm -rf "${CLOUD_HOME}/kafka_${pkg_kafka_scala_ver}-${pkg_kafka_ver}"
269297
rm -rf "${CLOUD_HOME}/spark-${pkg_spark_ver}-bin-without-hadoop"
270298
rm -rf "${CLOUD_HOME}/tmp"
271-
if [ -a "${CLOUD_HOME}/zookeeper.out" ]; then rm "${CLOUD_HOME}/zookeeper.out"; fi #hahahaha
299+
if [[ -a "${CLOUD_HOME}/zookeeper.out" ]]; then rm "${CLOUD_HOME}/zookeeper.out"; fi #hahahaha
272300
}
273301

274302
function clear_data {
@@ -279,15 +307,23 @@ function clear_data {
279307
rm -rf ${CLOUD_HOME}/data/dfs/name/*
280308
rm -rf ${CLOUD_HOME}/data/hadoop/tmp/*
281309
rm -rf ${CLOUD_HOME}/data/hadoop/pid/*
282-
if [ -d "${CLOUD_HOME}/data/kafka-logs" ]; then rm -rf ${CLOUD_HOME}/data/kafka-logs; fi # intentionally to clear dot files
310+
if [[ -d "${CLOUD_HOME}/data/kafka-logs" ]]; then rm -rf ${CLOUD_HOME}/data/kafka-logs; fi # intentionally to clear dot files
283311
}
284312

285313
function show_help {
286314
echo "Provide 1 command: (init|start|stop|reconfigure|reyarn|clean|help)"
287-
echo "If the environment variable GEOSERVER_HOME is set then the parameter '-gs' may be used with 'start' to automatically start/stop GeoServer with the cloud."
315+
echo "If the environment variable GEOSERVER_HOME is set then the parameter '-gs' may be used with 'start' to automatically start/stop GeoServer with the cloud."
288316
}
289317

290-
if [ "$#" -ne 1 ]; then
318+
if [[ "$2" -eq "-gs" ]]; then
319+
if [[ -n "${GEOSERVER_HOME}" && -e $GEOSERVER_HOME/bin/startup.sh ]]; then
320+
GEOSERVER_ENABLED=1
321+
else
322+
echo "The environment variable GEOSERVER_HOME is not set or is not valid."
323+
fi
324+
fi
325+
326+
if [[ "$#" -ne 1 && ! $GEOSERVER_ENABLED ]]; then
291327
show_help
292328
exit 1
293329
fi
@@ -306,10 +342,6 @@ elif [[ $1 == 'start' ]]; then
306342
echo "Starting cloud..."
307343
start_cloud
308344
echo "Cloud Started"
309-
if [[ $2 == '-gs' && -n "${GEOSERVER_HOME}" ]]; then
310-
trap stop_cloud SIGINT
311-
($GEOSERVER_HOME/bin/startup.sh)
312-
fi
313345
elif [[ $1 == 'stop' ]]; then
314346
echo "Stopping Cloud..."
315347
stop_cloud

bin/config.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ function set_env_vars {
6666
export YARN_IDENT_STRING="${HADOOP_IDENT_STRING}"
6767

6868
export SPARK_HOME="$CLOUD_HOME/spark-${pkg_spark_ver}-bin-without-hadoop"
69+
70+
export GEOSERVER_DATA_DIR="${CLOUD_HOME}/data/geoserver"
71+
export GEOSERVER_PID_DIR="${GEOSERVER_DATA_DIR}/pid"
72+
export GEOSERVER_LOG_DIR="${GEOSERVER_DATA_DIR}/log"
6973

7074
[[ $acc_enable -eq 1 ]] && export ACCUMULO_HOME="$CLOUD_HOME/accumulo-${pkg_accumulo_ver}"
7175
[[ $hbase_enable -eq 1 ]] && export HBASE_HOME="${CLOUD_HOME}/hbase-${pkg_hbase_ver}"

0 commit comments

Comments
 (0)