Skip to content

Instantly share code, notes, and snippets.

@cinhtau
Last active February 16, 2018 11:44
Show Gist options
  • Save cinhtau/fd82a586ba91f63a7913f476be6ea4b0 to your computer and use it in GitHub Desktop.
Save cinhtau/fd82a586ba91f63a7913f476be6ea4b0 to your computer and use it in GitHub Desktop.
Bash script for RiskShield Data Server, use it as template 😉 License=https://choosealicense.com/licenses/mit/
#!/usr/bin/env bash
STAGE="test"
CHANNEL="issuing"
RSS="/opt/RiskShield/Resources/RS-Server/$CHANNEL/$STAGE/current"
jdbc="/opt/RiskShield/Resources/JDBC/ojdbc6.jar"
# works with symlink
RSH="/opt/RiskShield/$CHANNEL/$STAGE/DataServer"
GCLOG="/var/log/RiskShield//$CHANNEL/$STAGE/cur/data_server_gc-$(date +'%Y%m%d%H%M').log"
CMD_PORT=7881
export LANG="en_US"
COLOR_SUCCESS="\\033[1;32m"
COLOR_FAILURE="\\033[1;31m"
COLOR_WARNING="\\033[1;33m"
COLOR_NORMAL="\\033[0;39m"
HEADER=$(printf '=%.0s' {1..60})
# change into homedir of riskshield-server
cd $RSH
echo_success() {
echo -n -e $"[$COLOR_SUCCESS OK $COLOR_NORMAL]"
}
echo_stopped() {
echo -n -e $"[$COLOR_FAILURE STOP $COLOR_NORMAL]"
}
# reload project configuration
reload_project() {
echo -n "Reload project.ini"
/usr/bin/java -classpath "${RSS}/lib/rss.jar" com.riskshield.server.tools.ReloadProjectConfig -p${CMD_PORT} -t0
}
reload_log(){
echo -n "Reload log4j.properties"
/usr/bin/java -classpath "${RSS}/lib/rss.jar" com.riskshield.server.tools.ReloadLog4jProperties -p${CMD_PORT} -t0
}
case "$1" in
start)
echo -n " == Starting RiskShield Data Server: "
/usr/bin/java -Drss.configuration.propertiesFile="../rss_config.properties" \
-Djava.library.path=${RSS}/bin \
-server \
-Xmx2G -Xms2G \
-classpath "/usr/share/java/*:${RSH}/.:$jdbc:${RSS}/lib/*" \
-XX:+UseG1GC \
-Xloggc:$GCLOG \
-verbose:GC \
-XX:+PrintGCDetails \
-XX:+PrintGCTimeStamps \
-XX:+PrintGCDateStamps \
-XX:+UseGCLogFileRotation \
-XX:NumberOfGCLogFiles=25 \
-XX:GCLogFileSize=100K \
com.riskshield.server.Starter -idata_server.ini $* > /dev/null 2> /dev/null &
echo -en "[ DONE ]\n"
;;
debug)
/usr/bin/java -Drss.configuration.propertiesFile="../rss_config.properties" \
-Djava.library.path=${RSS}/bin \
-server \
-Xmx2G -Xms2G \
-classpath "/usr/share/java/*:${RSH}/.:$jdbc:${RSS}/lib/*" \
-XX:+UseG1GC \
-Xloggc:$GCLOG \
-verbose:GC \
-XX:+PrintGCDetails \
-XX:+PrintGCTimeStamps \
-XX:+PrintGCDateStamps \
-XX:+UseGCLogFileRotation \
-XX:NumberOfGCLogFiles=25 \
-XX:GCLogFileSize=100K \
com.riskshield.server.Starter -idata_server.ini $*
;;
stop)
echo -en "Shutdown RiskShield Data Server: \n"
/usr/bin/java \
-Djava.library.path=${RSS}/bin \
-classpath "${RSS}/lib/rss.jar" com.riskshield.server.Shutdown -p${CMD_PORT}
;;
status)
STAT="$(ps -Af | grep '[j]ava.*tst/DataServer')"
if [[ $STAT ]]; then
echo -en "$HEADER\n"
echo_success && echo -e " RiskShield Data Server is $COLOR_SUCCESS running $COLOR_NORMAL"
echo -en "$HEADER\n"
echo -en "$STAT\n"
else
echo -en "$HEADER\n"
echo_stopped && echo -e " RiskShield Data Server is $COLOR_WARNING not running $COLOR_NORMAL"
echo -en "$HEADER\n"
fi
;;
reload)
reload_project
reload_log
;;
*)
echo "Usage: data_server.sh {start|stop|status|reload|debug}"
exit 3
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment