jboss7-jboss的自启动

1、了解sysv-rc-conf

2、脚本如下,放在/etc/init.d下面:

#!/bin/sh
### BEGIN INIT INFO
# Provides:       jboss & pinqidesign
# Required-Start:
# Required-Stop:
# Default-Start: 1
# Default-Stop:
# Description:    jboss start and stop script
### END INIT INFO
EXEC=/opt/wildfly/bin/standalone.sh
CLIEXEC=/opt/wildfly/bin/jboss-cli.sh

PIDFILE=/var/run/jboss.pid


case "$1" in
    start)
        if [ -f $PIDFILE ]
        then
                echo "$PIDFILE exists, process is already running or crashed"
        else
                echo "Starting jboss server..."
                 nohup $EXEC > /opt/jbossnohup.out & echo $! > ${PIDFILE}
        fi
        ;;
    stop)
        if [ ! -f $PIDFILE ]
        then
                echo "$PIDFILE does not exist, process is not running"
        else
                PID=$(cat $PIDFILE)
                echo "Stopping ..."
                $CLIEXEC --connect command=:shutdown
		rm ${PIDFILE}
                while [ -x /proc/${PID} ]
                do
                    echo "Waiting for jboss to shutdown ..."
                    sleep 1
                done
                echo "Jboss stopped"
        fi
        ;;
    *)
        echo "Please use start or stop as first argument"
        ;;
esac
3、注意事项:在jboss的standalone.sh和jboss-cli.sh中分别添加java环境变量:
#!/bin/sh
export JAVA_HOME="/opt/jdk1.8.0_60/"
export PATH="$PATH:$JAVA_HOME/bin:/opt/voltdb-voltdb-5.7beta/bin/"
export JRE_HOME="$JAVA_HOME/jre"
export CLASSPATH=".:$JAVA_HOME/lib:$JRE_HOME/lib"


4、脚本放好后,执行sysv-rc-config jboss on,这里jboss是自己所使用的脚本文件名,可任意取


你可能感兴趣的:(jboss,ubuntu,jboss7,自启动)