Skip to content

Instantly share code, notes, and snippets.

@cinhtau
Last active February 16, 2018 11:44
Show Gist options
  • Save cinhtau/dfa0aa893203b944cf503d9083cfefc1 to your computer and use it in GitHub Desktop.
Save cinhtau/dfa0aa893203b944cf503d9083cfefc1 to your computer and use it in GitHub Desktop.
Bash script for RiskShield Decision 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"
JMS="/opt/RiskShield/Resources/JmsQueue"
# works with symlink
RSH="/opt/RiskShield/$CHANNEL/$STAGE/DecisionServer"
GCLOG="/var/log/RiskShield/$CHANNEL/$STAGE/cur/$(date +'%Y%-m%-d%-H%M')_decision_server_gc.log"
CMD_PORT=7891
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 = project.ini
reload_config(){
echo -n "Reload project.ini"
/usr/bin/java -classpath "${RSS}/lib/rss.jar" com.riskshield.server.tools.ReloadProjectConfig -p${CMD_PORT} -t0
}
# reload log4j.properties
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 Decision Server: "
/usr/bin/java -Drss.configuration.propertiesFile="../rss_config.properties" \
-Djava.library.path=${RSS}/bin \
-server \
-Xmx4G \
-Xms4G \
-classpath "/usr/share/java/*:${RSH}/.:$jdbc:${RSS}/lib/*:$JMS/*" \
-XX:+UseG1GC \
-Xloggc:$GCLOG \
-verbose:GC \
-XX:+PrintGCDetails \
-XX:+PrintGCTimeStamps \
-XX:+PrintGCDateStamps \
-XX:+UseGCLogFileRotation \
-XX:NumberOfGCLogFiles=25 \
-XX:GCLogFileSize=100K \
com.riskshield.server.Starter -idecision_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/*:$JMS/*" \
-XX:+UseG1GC \
-Xloggc:$GCLOG \
-verbose:GC \
-XX:+PrintGCDetails \
-XX:+PrintGCTimeStamps \
-XX:+PrintGCDateStamps \
-XX:+UseGCLogFileRotation \
-XX:NumberOfGCLogFiles=25 \
-XX:GCLogFileSize=100K \
com.riskshield.server.Starter -idecision_server.ini $*
;;
stop)
echo -en "Shutting down RiskShield Decision 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 tpiss | grep '[j]ava.*tst/DecisionServer')"
if [[ $STAT ]]; then
echo -en "$HEADER\n"
echo_success && echo -e " RiskShield Decision 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 Decision Server is $COLOR_WARNING not running $COLOR_NORMAL"
echo -en "$HEADER\n"
fi
;;
reload)
reload_config
reload_log
;;
*)
echo "Usage: decision_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