Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.

Commit 4f35b71

Browse files
author
OpenShift Bot
committed
Merge pull request #6268 from tiwillia/bz1211526
Merged by openshift-bot
2 parents 3d6620c + 203d57b commit 4f35b71

1 file changed

Lines changed: 30 additions & 12 deletions

File tree

  • cartridges/openshift-origin-cartridge-haproxy/bin

cartridges/openshift-origin-cartridge-haproxy/bin/control

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ function wait_to_start() {
4141

4242
function _stop_haproxy_ctld() {
4343
if [ -f ${HAPROXY_CTLD_PID} ]; then
44-
pid=$( /bin/cat "${HAPROXY_CTLD_PID}" )
45-
if ps --no-headers --pid ${pid} > /dev/null 2>&1; then
46-
kill -TERM $pid
44+
local ctld_pid=$( /bin/cat "${HAPROXY_CTLD_PID}" )
45+
if ps --no-headers --pid ${ctld_pid} > /dev/null 2>&1; then
46+
kill -TERM $ctld_pid
4747
else
4848
rm -f ${HAPROXY_CTLD_PID}
4949
fi
@@ -147,15 +147,19 @@ function _stop_haproxy_service() {
147147
else
148148
if `pgrep -x haproxy > /dev/null 2>&1`
149149
then
150-
echo "Warning: HAProxy process exists without a pid file. Use force-stop to kill." 1>&2
150+
client_message "Warning: HAProxy process exists without a pid file."
151151
else
152-
echo "HAProxy already stopped" 1>&2
152+
client_message "HAProxy already stopped"
153153
fi
154154
fi
155155
}
156156

157157
function _restart_haproxy_service() {
158-
_stop_haproxy_service || pkill haproxy || :
158+
_stop_haproxy_service
159+
if `pgrep -x haproxy > /dev/null 2>&1`; then
160+
client_message "Could not stop HAProxy. Forcefully killing the process."
161+
pkill haproxy
162+
fi
159163
_start_haproxy_service
160164
}
161165

@@ -175,17 +179,31 @@ function _reload_service() {
175179

176180
function start() {
177181
_start_haproxy_service
178-
isrunning && echo "HAProxy instance is started"
182+
if isrunning; then
183+
client_result "HAProxy instance is started"
184+
else
185+
client_error "HAProxy instance could not be started"
186+
exit 1
187+
fi
179188
}
180189

181190
function stop() {
182191
_stop_haproxy_service
183-
isrunning || echo "HAProxy instance is stopped"
192+
if `pgrep -x haproxy > /dev/null 2>&1`; then
193+
client_message "Could not stop HAProxy. Forcefully killing the process."
194+
pkill haproxy
195+
if `pgrep -x haproxy > /dev/null 2>&1`; then
196+
client_error "Could not stop the HAProxy process."
197+
exit 1
198+
fi
199+
fi
200+
201+
client_result "HAProxy instance is stopped"
184202
}
185203

186204
function restart() {
187205
_restart_haproxy_service
188-
isrunning && echo "Restarted HAProxy instance"
206+
isrunning && client_result "Restarted HAProxy instance"
189207
}
190208

191209
function reload() {
@@ -196,14 +214,14 @@ function reload() {
196214
_reload_service
197215
fi
198216

199-
isrunning && echo "Reloaded HAProxy instance"
217+
isrunning && client_result "Reloaded HAProxy instance"
200218
}
201219

202220
function force-reload() {
203221
if isrunning; then
204-
echo "`date`: Conditionally reloading HAProxy service " 1>&2
222+
client_message "`date`: Conditionally reloading HAProxy service "
205223
_reload_service
206-
isrunning && echo "Conditionally reloaded HAProxy"
224+
isrunning && client_result "Conditionally reloaded HAProxy"
207225
fi
208226
}
209227

0 commit comments

Comments
 (0)