2014년 4월 24일 목요일

how to service registering the service for runnable jar file on centos

vi /etc/init.d/astmiddleware

#! /bin/sh
### BEGIN INIT INFO
# Provides:          musesoft
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# X-Interactive:     false
# Short-Description: service init script
# Description:       Start/stop an service script
### END INIT INFO

DESC="astmiddleware"
NAME=astmiddleware
#DAEMON=

do_start()
{
   echo "starting!";
}

do_stop()
{
   echo "stopping!"
}

case "$1" in
      start)
            cd /usr/local/src/astmiddleware
            /usr/bin/java -jar astmiddleware.jar &
            ;;
      stop)
            killall -v java
            ;;
esac
exit 0

chmod a+rx /etc/init.d/astmiddleware
chkconfig --add /usr/local/src/astmiddleware

chkconfig --list

chkconfig --del astmiddleware

댓글 없음: