Created
October 23, 2014 06:40
-
-
Save bejean/3c448555cc79efa9ed7d to your computer and use it in GitHub Desktop.
dropwizard init.d sample script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# | |
# chkconfig: 2345 90 10 | |
# description: solr-fs-indexer daemon | |
. /etc/init.d/functions | |
# You will probably want to change only two following lines. | |
BASEDIR="/opt/rnglobal/indexer" | |
USER="root" | |
PROG="solr-fs-indexer" | |
CMD="java -jar solr-fs-indexer.jar server settings.yml" | |
PIDFILE="${BASEDIR}/indexer.pid" | |
RETVAL=0 | |
start () { | |
echo -n $"Starting ${PROG}" | |
if ( [ -f ${PIDFILE} ] ) | |
then | |
echo -n "${PROG} is already running." | |
failure ; echo | |
RETVAL=1 | |
return | |
fi | |
touch ${PIDFILE} ; chown ${USER} ${PIDFILE} | |
runuser ${USER} -c "cd ${BASEDIR} | |
${CMD} > /dev/null & | |
echo \$! > ${PIDFILE}" | |
success ; echo | |
} | |
stop () { | |
echo -n $"Stopping ${PROG}" | |
if ( [ ! -f ${PIDFILE} ] ) | |
then | |
echo -n "${PROG} is not running." | |
failure ; echo | |
RETVAL=1 | |
return | |
fi | |
killproc -p ${PIDFILE} | |
RETVAL=$? | |
echo | |
if [ $RETVAL -eq 0 ] ; then | |
rm -f ${PIDFILE} | |
fi | |
} | |
status () { | |
if ( [ -f ${PIDFILE} ] ) | |
then | |
echo -n "${PROG} is running." | |
else | |
echo -n "${PROG} is not running." | |
fi | |
echo | |
} | |
restart () { | |
stop | |
start | |
} | |
# See how we were called. | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status | |
;; | |
restart) | |
restart | |
;; | |
*) | |
echo $"Usage: $0 {start|stop}" | |
RETVAL=2 | |
;; | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment