本文介绍了启动Hudson的Init.d脚本无法在Ubuntu上启动时运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用init.d脚本在启动时自动在Ubuntu上启动Hudson.手动调用时,脚本运行良好(例如,以./hudson启动),并且在rc2-rc5中具有update-rc.d生成的符号链接,但在重新启动时不会启动.有谁知道是什么原因导致它无法正常工作?脚本如下(hudson.log日志文件在启动时创建,但不包含任何输出):

I'm trying to start Hudson on Ubuntu automatically on boot with an init.d script. The script works fine when invoked manually (ie with ./hudson start), and has update-rc.d-generated sym-links in rc2-rc5, but it doesn't start on rebooting. Does anyone know what might be causing it to not work? The script is as follows (the hudson.log logfile is created at boot, but doesn't contain any output):


#!/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

推荐答案

如果它是手动运行的,则表示脚本没有任何问题...确保将其复制/移动到/etc/init.d文件夹中,并检查rc [2345] .d目录中的链接文件.

if its run manually, meaning there is nothing wrong with the script...make sure you copy/move it in /etc/init.d folder and check your link files in rc[2345].d dirs.

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

这篇关于启动Hudson的Init.d脚本无法在Ubuntu上启动时运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 06:23