Repository navigation
Expand file tree
/
Copy pathhudson.init.in
More file actions
158 lines (146 loc) · 5.27 KB
/
Copy pathhudson.init.in
File metadata and controls
158 lines (146 loc) · 5.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/sh
#
# SUSE system statup script for Hudson
# Copyright (C) 2007 Pascal Bleser
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or (at
# your option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
# USA.
#
### BEGIN INIT INFO
# Provides: hudson
# Required-Start: $local_fs $remote_fs $network $time $named
# Should-Start: $time sendmail
# Required-Stop: $local_fs $remote_fs $network $time $named
# Should-Stop: $time sendmail
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Hudson continuous build server
# Description: Start the Hudson continuous build server
### END INIT INFO
# Check for missing binaries (stale symlinks should not happen)
HUDSON_WAR="@@WAR@@"
test -r "$HUDSON_WAR" || { echo "$HUDSON_WAR not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
# Check for existence of needed config file and read it
HUDSON_CONFIG=/etc/sysconfig/hudson
test -e "$HUDSON_CONFIG" || { echo "$HUDSON_CONFIG not existing";
if [ "$1" = "stop" ]; then exit 0;
else exit 6; fi; }
test -r "$HUDSON_CONFIG" || { echo "$HUDSON_CONFIG not readable. Perhaps you forgot 'sudo'?";
if [ "$1" = "stop" ]; then exit 0;
else exit 6; fi; }
HUDSON_PID_FILE="/var/run/hudson.pid"
# Source function library.
. /etc/init.d/functions
# Read config
[ -f "$HUDSON_CONFIG" ] && . "$HUDSON_CONFIG"
# Set up environment accordingly to the configuration settings
[ -n "$HUDSON_HOME" ] || { echo "HUDSON_HOME not configured in $HUDSON_CONFIG";
if [ "$1" = "stop" ]; then exit 0;
else exit 6; fi; }
[ -d "$HUDSON_HOME" ] || { echo "HUDSON_HOME directory does not exist: $HUDSON_HOME";
if [ "$1" = "stop" ]; then exit 0;
else exit 1; fi; }
export HUDSON_HOME
# Search usable Java. We do this because various reports indicated
# that /usr/bin/java may not always point to Java 1.5
# see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html
for candidate in /usr/lib/jvm/java-1.6.0/bin/java /usr/lib/jvm/jre-1.6.0/bin/java /usr/lib/jvm/java-1.5.0/bin/java /usr/lib/jvm/jre-1.5.0/bin/java /usr/bin/java
do
[ -x "$HUDSON_JAVA_CMD" ] && break
HUDSON_JAVA_CMD="$candidate"
done
JAVA_CMD="$HUDSON_JAVA_CMD $HUDSON_JAVA_OPTIONS -DHUDSON_HOME=$HUDSON_HOME -jar $HUDSON_WAR"
PARAMS="--logfile=/var/log/hudson/hudson.log --daemon"
[ -n "$HUDSON_PORT" ] && PARAMS="$PARAMS --httpPort=$HUDSON_PORT"
[ -n "$HUDSON_DEBUG_LEVEL" ] && PARAMS="$PARAMS --debug=$HUDSON_DEBUG_LEVEL"
[ -n "$HUDSON_HANDLER_STARTUP" ] && PARAMS="$PARAMS --handlerCountStartup=$HUDSON_HANDLER_STARTUP"
[ -n "$HUDSON_HANDLER_MAX" ] && PARAMS="$PARAMS --handlerCountMax=$HUDSON_HANDLER_MAX"
[ -n "$HUDSON_HANDLER_IDLE" ] && PARAMS="$PARAMS --handlerCountMaxIdle=$HUDSON_HANDLER_IDLE"
[ -n "$HUDSON_ARGS" ] && PARAMS="$PARAMS $HUDSON_ARGS"
if [ "$HUDSON_ENABLE_ACCESS_LOG" = "yes" ]; then
PARAMS="$PARAMS --accessLoggerClassName=winstone.accesslog.SimpleAccessLogger --simpleAccessLogger.format=combined --simpleAccessLogger.file=/var/log/hudson/access_log"
fi
RETVAL=0
case "$1" in
start)
echo -n "Starting Hudson "
daemon --user "$HUDSON_USER" --pidfile "$HUDSON_PID_FILE" $JAVA_CMD $PARAMS > /dev/null
RETVAL=$?
if [ $RETVAL = 0 ]; then
success
echo > "$HUDSON_PID_FILE" # just in case we fail to find it
MY_SESSION_ID=`/bin/ps h -o sess -p $$`
# get PID
/bin/ps hww -u "$HUDSON_USER" -o sess,ppid,pid,cmd | \
while read sess ppid pid cmd; do
[ "$ppid" = 1 ] || continue
# this test doesn't work because Hudson sets a new Session ID
# [ "$sess" = "$MY_SESSION_ID" ] || continue
echo "$cmd" | grep $HUDSON_WAR > /dev/null
[ $? = 0 ] || continue
# found a PID
echo $pid > "$HUDSON_PID_FILE"
done
else
failure
fi
echo
;;
stop)
echo -n "Shutting down Hudson "
killproc hudson
RETVAL=$?
echo
;;
try-restart|condrestart)
if test "$1" = "condrestart"; then
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
fi
$0 status
if test $? = 0; then
$0 restart
else
: # Not running is not a failure.
fi
;;
restart)
$0 stop
$0 start
;;
force-reload)
echo -n "Reload service Hudson "
$0 try-restart
;;
reload)
$0 restart
;;
status)
status hudson
RETVAL=$?
;;
probe)
## Optional: Probe for the necessity of a reload, print out the
## argument to this init script which is required for a reload.
## Note: probe is not (yet) part of LSB (as of 1.9)
test "$HUDSON_CONFIG" -nt "$HUDSON_PID_FILE" && echo reload
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
exit 1
;;
esac
exit $RETVAL