2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 11:01:09 +00:00

Cleanly handle stop/restart when not running

Previously some rather uncomfortable looking output would be emitted at someone trying to restart
confluent if not running.  Be nicer and recognize when service is not running and a stop attempt is made.
This commit is contained in:
Jarrod Johnon 2014-11-18 17:02:54 -05:00
parent bf15f12a1c
commit 059b448932
2 changed files with 14 additions and 3 deletions

View File

@ -19,6 +19,7 @@
# It implement unix and tls sockets
#
import atexit
import os
import pwd
import stat
@ -222,6 +223,11 @@ def _tlsstartup(cnn):
server_side=True)
sessionhdl(cnn, authname)
def removesocket():
try:
os.remove("/var/run/confluent/api.sock")
except OSError:
pass
def _unixdomainhandler():
unixsocket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
@ -233,6 +239,7 @@ def _unixdomainhandler():
os.chmod("/var/run/confluent/api.sock",
stat.S_IWOTH | stat.S_IROTH | stat.S_IWGRP |
stat.S_IRGRP | stat.S_IWUSR | stat.S_IRUSR)
atexit.register(removesocket)
unixsocket.listen(5)
while True:
cnn, addr = unixsocket.accept()

View File

@ -21,8 +21,10 @@ fi
case $1 in
restart)
echo -n 'Stopping Confluent '
/opt/confluent/bin/confetty shutdown /
if [ -S /var/run/confluent/api.sock ]; then
echo -n 'Stopping Confluent '
/opt/confluent/bin/confetty shutdown /
fi
echo -n 'Starting Confluent '
/opt/confluent/bin/confluent
$LOG_SUCCESS
@ -34,7 +36,9 @@ case $1 in
;;
stop)
echo -n 'Stopping Confluent '
/opt/confluent/bin/confetty shutdown /
if [ -S /var/run/confluent/api.sock ]; then
/opt/confluent/bin/confetty shutdown /
fi
$LOG_SUCCESS
;;
esac