机器启动时服务不启动 - Ubuntu 14.04.1 LTS

机器启动时服务不启动 - Ubuntu 14.04.1 LTS

我通过在目录中创建 weblogic 文件来创建Weblogic服务器,以便service在机器启动时启动/etc/init.d/内容如下:

#!/bin/sh

. /etc/default/weblogic

start() {
    nohup ${WLSHOME}/server/bin/startNodeManager.sh && ${WLSHOME}/common/bin/wlst.sh /opt/nmstart-${ADMINSERVER}.py
    for i in $SERVERS; do
    ${WLSHOME}/common/bin/wlst.sh /opt/start-"$i".py &
    done
}

stop() {
      ${DOMAINPATH}/bin/stopWebLogic.sh -username ${USER} -password ${PASSWORD}
}

case "$1" in
start)
    start
    ;;
stop)
    stop
    ;;
restart)
    stop
    start
    ;;
*)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
esac

目录中还有另一个同名文件(weblogic)/etc/default/内容如下:

# /etc/default/weblogic script used to configure the init script
WLSHOME="/opt/weblogic/wlserver_10.3"
DOMAINPATH="/opt/weblogic/projects/test"

# Username password for stopping
USER="weblogic"
PASSWORD="weblogic1"

# Servers to start
SERVERS="wlserver-1 wlserver-2 "
ADMINSERVER="AdminServer"

当我运行命令时sudo service weblogic start,服务器启动,但重新启动机器时 weblogic 服务未启动。

然后,我跟着问题让它发挥作用,但它们对我都不起作用。

PS:运行命令sudo update-rc.d weblogic defaults,给出输出:

update-rc.d: warning: /etc/init.d/weblogic missing LSB information
update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
System start/stop links for /etc/init.d/weblogic already exist.

知道如何让 weblogic 服务在机器启动时启动吗?

谢谢,任何帮助都将不胜感激。

答案1

最后我找到了问题的答案,并想与未来的读者分享,问题是禁止开始块中使用的命令:

start() {
    nohup ${WLSHOME}/server/bin/startNodeManager.sh && ${WLSHOME}/common/bin/wlst.sh /opt/nmstart-${ADMINSERVER}.py
    for i in $SERVERS; do
    ${WLSHOME}/common/bin/wlst.sh /opt/start-"$i".py &
    done
}

机器重启时,nohup 被忽略制作 NodeManager 脚本not to run as a background process我可以看到/var/log/boot.log文件:

nohup: ignoring input and appending output to 'nohup.out'

因此,调整开始块以使用与号 (&)为了running the NodeManager script in background instead of nohup工作如下:

start() {
        ${WLSHOME}/server/bin/startNodeManager.sh &
        ${WLSHOME}/common/bin/wlst.sh /opt/nmstart-${ADMINSERVER}.py
        for i in $SERVERS; do
        ${WLSHOME}/common/bin/wlst.sh /opt/start-"$i".py
        done
}

相关内容