IBContoller init script
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: IBController | |
# Short-Description: starts instance of IBController | |
# Description: starts instance of IBController using start-stop-daemon | |
### END INIT INFO | |
############### EDIT ME ################## | |
# ini file | |
INI=demo | |
# IB-Controller jar | |
JAR=ibcontroller-2.11.20140324.jar | |
# path to app | |
APP_PATH=/usr/share/java | |
# user | |
RUN_AS=root | |
# path to xvfb bin | |
DAEMON=/usr/bin/xvfb-run | |
# Path to store PID file | |
PID_FILE=/var/run/ibcontroller/xvfb.pid | |
PID_PATH=$(dirname $PID_FILE) | |
# script name | |
NAME=ibcontroller | |
# app name | |
DESC=IB-Controller | |
# startup args | |
DAEMON_OPTS=" -a java -cp ${APP_PATH}/ib-gateway/jts.jar:${APP_PATH}/ib-gateway/total.2013.jar:${APP_PATH}/ibcontroller/${JAR} -Xmx512M -XX:MaxPermSize=128M ibcontroller.IBGatewayController /etc/ibcontroller/${INI}.ini" | |
############### END EDIT ME ################## | |
test -x $DAEMON || exit 0 | |
set -e | |
case "$1" in | |
start) | |
echo "Starting $DESC" | |
rm -rf $PID_PATH || return 1 | |
install -d --mode=0755 -o $RUN_AS $PID_PATH || return 1 | |
start-stop-daemon -d $APP_PATH -c $RUN_AS --start --background --pidfile $PID_FILE --make-pidfile --exec $DAEMON -- $DAEMON_OPTS | |
;; | |
stop) | |
echo "Stopping $DESC" | |
# start-stop-daemon --stop --pidfile $PID_FILE --retry 15 | |
# hacky kill command because we can't get PID of java process when starting daemon | |
pgrep -f "(${JAR}.*${INI}.ini)" | xargs kill -9 | |
;; | |
restart|force-reload) | |
echo "Restarting $DESC" | |
# start-stop-daemon --stop --pidfile $PID_FILE --retry 15 | |
# hacky kill command because we can't get PID of java process when starting daemon | |
pgrep -f "(${JAR}.*${INI}.ini)" | xargs kill -9 | |
start-stop-daemon -d $APP_PATH -c $RUN_AS --start --background --pidfile $PID_FILE --make-pidfile --exec $DAEMON -- $DAEMON_OPTS | |
;; | |
*) | |
N=/etc/init.d/$NAME | |
echo "Usage: $N {start|stop|restart|force-reload}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment