Skip to content

Instantly share code, notes, and snippets.

@bejean
Created October 23, 2014 06:40
Show Gist options
  • Save bejean/3c448555cc79efa9ed7d to your computer and use it in GitHub Desktop.
Save bejean/3c448555cc79efa9ed7d to your computer and use it in GitHub Desktop.
dropwizard init.d sample script
#! /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