我想开始哈德森在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