前置き
- RHEL系を対象としたスクリプトです
- configurationのJSONファイルは、/etc/jubatusに置かれる前提です
- jubaclassifierのみを対象としています
- スタンドアロンのみを対象としています
設置
/etc/init.d に置く。
使い方
$ sudo service jubatus-classifier
Usage : /etc/init.d/jubatus-classifier (start|stop|status|restart)
$ sudo service jubatus-classifier start
Starting jubatus-classifier: [ OK ]
$ sudo service jubatus-classifier status
jubatus-classifier (pid 11575) を実行中...
$ sudo service jubatus-classifier stop
Stopping jubatus-classifier: [ OK ]
$ sudo service jubatus-classifier restart
Stopping jubatus-classifier: [ OK ]
Starting jubatus-classifier: [ OK ]
ランレベルへの登録など
$ sudo chkconfig --add jubatus-classifier
$ sudo chkconfig --list jubatus-classifier
jubatus-classifier 0:off 1:off 2:off 3:off 4:off 5:off 6:off
$ sudo chkconfig --level 345 jubatus-classifier on
$ sudo chkconfig --list jubatus-classifier
jubatus-classifier 0:off 1:off 2:off 3:on 4:on 5:on 6:off
$ sudo chkconfig --del jubatus-classifier
#!/bin/sh
#
# chkconfig: - 99 32
# Source function library
. /etc/init.d/functions
SERVICENAME="jubatus-classifier"
RETVAL=0
PIDFILE=/var/run/jubatus-classifier.pid
JUBACLASSIFIER=/usr/bin/jubaclassifier
CONFIG=/etc/jubatus/config.json
#LOGDIR=/tmp
MODELDIR=/tmp
LOGCONFIG=/usr/share/jubatus/example/log/log4cxx.xml
start() {
echo -n "Starting ${SERVICENAME}:"
${JUBACLASSIFIER} -f ${CONFIG} -d ${MODELDIR} -g ${LOGCONFIG} &
RETVAL=$?
if [ ${RETVAL} = 0 ]; then
success
touch /var/lock/subsys/${SERVICENAME}
/sbin/pidof ${JUBACLASSIFIER} > ${PIDFILE}
else
failure
fi
echo
}
stop() {
echo -n "Stopping ${SERVICENAME}:"
killproc $JUBACLASSIFIER -TERM
RETVAL=$?
if [ ${RETVAL} -eq 0 ]; then
rm -f /var/lock/subsys/${SERVICENAME}
rm -f ${PIDFILE}
fi
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status ${SERVICENAME}
;;
restart)
stop
start
;;
*)
echo "Usage : $0 (start|stop|status|restart)"
RETVAL=1
esac
exit ${RETVAL}