update
This commit is contained in:
70
xxl-job/ADD/ccmd
Executable file
70
xxl-job/ADD/ccmd
Executable file
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
|
||||
##################################################
|
||||
# Mount dir #
|
||||
# - /data/applogs #
|
||||
# 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 ModifyConf {
|
||||
sed -i 's/^M//g' $JAR.properties
|
||||
local kv=
|
||||
Print Modify $JAR.properties ...
|
||||
while read kv; do
|
||||
[ -z "$kv" ] && return 0
|
||||
Print Modify property: ${kv%%=*} ...
|
||||
sed -i "/^${kv%%=*} *=/c$kv" $JAR.properties
|
||||
done <<< "$(env | grep '^_CONF_' | sed 's/_CONF_//')"
|
||||
}
|
||||
|
||||
function StartProc {
|
||||
Print Start $JAR ...
|
||||
java $JAVA_OPTS \
|
||||
-jar $JAR.jar \
|
||||
--spring.config.location=$JAR.properties \
|
||||
>/dev/null \
|
||||
2>>logs/$JAR.out &
|
||||
PIDS="$PIDS $!"
|
||||
}
|
||||
|
||||
function Main {
|
||||
local pid=
|
||||
cd /opt/
|
||||
ModifyConf
|
||||
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