当前位置: 首页 > 工具软件 > light-daemon > 使用案例 >

start-stop-daemon example

饶德元
2023-12-01
#!/bin/sh

DESC="mock system"
NAME="mocksystem"
PIDFILE=/var/run/$NAME.pid
#RUN_AS=hudson
RUN_AS=zhus


EXE=/usr/bin/ant


d_start() {
    start-stop-daemon --start --quiet --background --m --pidfile $PIDFILE --chuid $RUN_AS --exec $EXE -- -f /home/zhus/system360/system-light/build.xml run-dist

}

d_stop() {
        start-stop-daemon --stop --quiet --pidfile $PIDFILE
        if [ -e $PIDFILE ]; then
                rm $PIDFILE
        fi
}

case $1 in
        start)
                echo -n "Strating $DESC: $NAME"
                d_start
                echo "."
                ;;
        stop)
                echo -n "Stopping $DESC: $NAME"
                d_stop
                echo "."
                ;;
        restart)
                echo -n "Restarting $DESC: $NAME"
                d_stop
                sleep 1
                d_start
                echo "."
                ;;
        *)
                echo "usage: $NAME {start|stop|restart}"
                exit 1
                ;;
esac

exit 0

 类似资料: