的init.d脚本启动哈德森并不在Ubuntu上运行启动(Init.d script to star

2019-10-29 08:47发布

我想开始哈德森在Ubuntu上用的init.d脚本,开机自动。 手动调用(即./hudson开始),并在RC2-RC5更新rc.d的生成符号链接时,该脚本能正常工作,但它不重新启动启动。 有谁知道可能会导致其无法正常工作? 该脚本如下(hudson.log日志文件在启动创建,但不包含任何输出):


#!/bin/sh
### BEGIN INIT INFO
# Provides:          hudson
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start Hudson at boot
# Description:       Start the Hudson CI server at boot
### END INIT INFO

CTL=/home/jcss-dev/hudson.war
LOGFILE=/home/jcss-dev/hudson.log

case "$1" in
    start)
                pid=`/bin/ps -Af | /bin/grep "hudson.war" | /bin/grep -v /bin/grep | /usr/bin/awk '{print $2}'`
                if [ "$pid" = "" ]; then
      echo -n "Starting Hudson... "
                    su - the-user-account-name -c "/usr/bin/java -jar $CTL > $LOGFILE 2>&1 &"
  else
      echo -n "Hudson is already running"
  fi
        ;;
    stop)
  pid=`/bin/ps -Af | /bin/grep "hudson.war" | /bin/grep -v /bin/grep | /usr/bin/awk '{print $2}'`
  if [ "$pid" != "" ]; then
      echo -n "Stopping Hudson... "
      kill -9 $pid
  else
      echo "Hudson is not running"
  fi
        ;;
    status)
                pid=`/bin/ps -Af | /bin/grep "hudson.war" | /bin/grep -v /bin/grep | /usr/bin/awk '{print $2}'`
                if [ "$pid" != "" ]; then
      echo -n "Hudson is running"
  else
      echo -n "Hudson is not running"
  fi
        ;;
    *)
        echo "Usage $0 start|stop|status"
        exit 1
        ;;
esac

exit 0

Answer 1:

如果手动运行,这意味着没有什么错的脚本...确保您复制/在/etc/init.d文件夹移动它,并为您在RC [2345]你的链接文件.D迪尔斯。

也许这个问题应该在serverfault.com



Answer 2:

您已经添加了它的rc?

sudo update-rc.d hudson.sh defaults

这个对我有用...



Answer 3:

在问过基本问题的风险,我假设在你的脚本的开头部分的su命令有“JCSS-dev的”到位“的用户帐户名称”的?



文章来源: Init.d script to start Hudson doesn't run at boot on Ubuntu