forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloud-management.rc
More file actions
executable file
·107 lines (100 loc) · 2.67 KB
/
Copy pathcloud-management.rc
File metadata and controls
executable file
·107 lines (100 loc) · 2.67 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
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# cloudstack-management This shell script takes care of starting and stopping Tomcat
#
# chkconfig: - 80 20
#
### BEGIN INIT INFO
# Provides: tomcat6
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start:
# Default-Stop:
# Description: Release implementation for Servlet 2.5 and JSP 2.1
# Short-Description: start and stop tomcat
### END INIT INFO
#
# - originally written by Henri Gomez, Keith Irwin, and Nicolas Mailhot
# - heavily rewritten by Deepak Bhole and Jason Corley
#
if [ -r /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi
if [ -r /lib/lsb/init-functions ]; then
. /lib/lsb/init-functions
fi
NAME="$(basename $0)"
stop() {
SHUTDOWN_WAIT="30"
count="0"
if [ -f /var/run/${NAME}.pid ]; then
pid=`cat /var/run/${NAME}.pid`
kill $pid &>/dev/null
until [ "$(ps --pid $pid | grep -c $pid)" -eq "0" ] || \
[ "$count" -gt "$SHUTDOWN_WAIT" ]
do
sleep 1
let count="${count}+1"
done
if [ "$(ps --pid $pid | grep -c $pid)" -eq "0" ]; then
log_success_msg "Stopping ${NAME}:"
else
log_failure_msg "Stopping ${NAME}:"
fi
else
echo "Cannot find PID file of ${NAME}"
log_failure_msg "Stopping ${NAME}:"
fi
}
set_ulimit() {
fd_limit=`ulimit -n`
if [ "$fd_limit" != "4096" ]; then
user=`whoami`
if [ $user == "root" ]; then
ulimit -n 4096
fi
fi
}
handle_pid_file() {
if [ "$1" -ne 0 ] ; then
echo "The pid file locates at /var/run/${NAME}.pid and lock file at /var/lock/subsys/${NAME}.
Starting ${NAME} will take care of them or you can manually clean up."
fi
}
# See how we were called.
case "$1" in
status)
status ${NAME}
RETVAL=$?
handle_pid_file $RETVAL
;;
stop)
stop
;;
restart)
stop
set start
set_ulimit
. /etc/rc.d/init.d/tomcat6
;;
*)
set_ulimit
. /etc/rc.d/init.d/tomcat6
esac
exit $RETVAL