update
This commit is contained in:
64
tomcat/ADD/ccmd
Executable file
64
tomcat/ADD/ccmd
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
##################################################
|
||||
# Mount dir #
|
||||
# - /opt/tomcat/webapps #
|
||||
# - /opt/tomcat/logs #
|
||||
# ENV #
|
||||
# - JAVA_OPTS #
|
||||
##################################################
|
||||
|
||||
set -euo pipefail
|
||||
export LANG=en_US.UTF-8
|
||||
trap Quit EXIT
|
||||
|
||||
PIDS=
|
||||
GOT_SIGTERM=
|
||||
export JAVA_OPTS="-server -Djava.security.egd=file:/dev/./urandom -Duser.timezone=GMT+08 ${JAVA_OPTS:-}"
|
||||
|
||||
function Print {
|
||||
local file=/dev/null
|
||||
[ '-f' = "$1" ] && file=$2 && shift && shift
|
||||
date +"[%F %T] $*" | tee -a $file
|
||||
}
|
||||
|
||||
function Quit {
|
||||
Print killing java ...
|
||||
while :; do
|
||||
pkill -f java && Print killing java ... || break
|
||||
sleep 1
|
||||
done
|
||||
Print Container stopped.
|
||||
test -n "$GOT_SIGTERM"
|
||||
}
|
||||
|
||||
function RestoreConf {
|
||||
if [ -z "$(ls conf/)" ]; then
|
||||
Print Restore default config files and quit ...
|
||||
tar zxf conf.tgz
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
function StartProc {
|
||||
Print Start tomcat ...
|
||||
./bin/catalina.sh run &> /dev/null &
|
||||
PIDS="$PIDS $!"
|
||||
}
|
||||
|
||||
function Main {
|
||||
local pid=
|
||||
cd /opt/tomcat
|
||||
RestoreConf
|
||||
StartProc
|
||||
trap "GOT_SIGTERM=1; Print Got SIGTERM ..." SIGTERM
|
||||
while [ -z "$GOT_SIGTERM" ] && sleep 1; do
|
||||
for pid in $PIDS; do
|
||||
[ ! -e /proc/$pid ] && Print Unexpected error! && exit
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
# Start here
|
||||
Main
|
||||
|
Reference in New Issue
Block a user