]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
radhttpcheck: Catch broken pipe error
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 24 May 2023 01:48:32 +0000 (21:48 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 24 May 2023 01:48:32 +0000 (21:48 -0400)
scripts/health/radhttpcheck/radhttpcheck.py
scripts/health/radhttpcheck/radhttpcheck.yml

index 5fe76f69fca0859380b233859f566baa45335df7..952d108df2778b6b684311910dd214d603ed5d37 100755 (executable)
@@ -40,7 +40,10 @@ class RadiusHealthCheckHandler(BaseHTTPRequestHandler):
         self.send_header("Content-Type", "application/json")
         self.send_header("Content-Length", str(len(content)))
         self.end_headers()
-        self.wfile.write(bytes(content, 'utf8'))
+        try:
+            self.wfile.write(bytes(content, 'utf8'))
+        except BrokenPipeError:
+            pass
 
     def codeToStr(self, code):
         code_map = {
@@ -109,6 +112,7 @@ class RadiusHealthCheckHandler(BaseHTTPRequestHandler):
         req.add_message_authenticator()
 
         # We now block until retries and timeout have expired
+        rsp = None
         try:
             rsp = client.SendPacket(req)
         except pyrad.packet.PacketError as e:
@@ -119,6 +123,7 @@ class RadiusHealthCheckHandler(BaseHTTPRequestHandler):
             self.genericResponse(500, json.dumps({"msg": "Internal error: " + str(e) })) # Internal error
         finally:
             del client # Ensure the socket is closed in a timely fashion
+        if not rsp:
             return
 
         # Deal with response code mismatches
index 12d06114dd1c1095af5a4cc68717da41dac92c5d..e1211cee1c6f6073ef2a1976753fc9336ff5fb71 100644 (file)
@@ -3,7 +3,7 @@ listen:
   address: '*'
   port: 8080
 # URLs the healthcheck script will respond on, and the various types of requests they create
-endpoints:
+healthchecks:
   '/acct':
     port: 1813
     secret: testing123