From e2bb72cc14caf054b7b27caefa3462be59aa6382 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 8 Jan 2025 15:59:48 -0500 Subject: [PATCH] Allow Unix socket for http socket If service.cfg has: [http] bindhost = /var/run/confluent/httpapi Then it will use the cited path to create a unix socket instead of a network socket. --- confluent_server/confluent/httpapi.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/httpapi.py b/confluent_server/confluent/httpapi.py index f3c0b1af..5048b8f8 100644 --- a/confluent_server/confluent/httpapi.py +++ b/confluent_server/confluent/httpapi.py @@ -1195,8 +1195,17 @@ def serve(bind_host, bind_port): sock = None while not sock: try: - sock = eventlet.listen( - (bind_host, bind_port, 0, 0), family=socket.AF_INET6) + if '/' in bind_host: + try: + os.remove(bind_host) + except Exception: + pass + sock = eventlet.listen( + bind_host, family=socket.AF_UNIX) + os.chmod(bind_host, 0o666) + else: + sock = eventlet.listen( + (bind_host, bind_port, 0, 0), family=socket.AF_INET6) except socket.error as e: if e.errno != 98: raise