diff --git a/confluent_server/confluent/sockapi.py b/confluent_server/confluent/sockapi.py index d8895d6e..1e8b3795 100644 --- a/confluent_server/confluent/sockapi.py +++ b/confluent_server/confluent/sockapi.py @@ -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() diff --git a/confluent_server/sysvinit/confluent b/confluent_server/sysvinit/confluent index 8423e313..6661a308 100755 --- a/confluent_server/sysvinit/confluent +++ b/confluent_server/sysvinit/confluent @@ -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