From 960e5574d071c87d054a8b0c379f8b238beb447f Mon Sep 17 00:00:00 2001 From: MunyDev Date: Fri, 24 Jan 2025 21:52:02 -0500 Subject: [PATCH] Added start_server.sh --- .gitignore | 3 ++- server.py | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 33fec00..baddd8a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .venv out -__pycache__ \ No newline at end of file +__pycache__ +pid \ No newline at end of file diff --git a/server.py b/server.py index a8dd33e..e0ca209 100644 --- a/server.py +++ b/server.py @@ -48,5 +48,14 @@ class A(BaseHTTPRequestHandler): self.wfile.write(dmr.SerializeToString()) # self.wfile.close() -hs = HTTPServer(("0.0.0.0", 3040), A) -hs.serve_forever() +print("Starting internal server!") +hs = HTTPServer(("0.0.0.0", 3040), A,bind_and_activate=False) +hs.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True) +hs.server_bind() +hs.server_activate() +try: + hs.serve_forever() +except BaseException as e: + print("Interrupted") + hs.server_close() +