Refactor sensor data publishing and health check server configuration. Updated MQTT topic structure for individual data points, improved error handling, and added garbage collection to manage memory. Enhanced logging for health check server accessibility and sensor status updates.
This commit is contained in:
@ -59,15 +59,17 @@ class HealthCheckServer:
|
||||
return
|
||||
|
||||
try:
|
||||
self.server = HTTPServer(('', self.port), HealthCheckHandler)
|
||||
# Bind to all interfaces to make it accessible from outside container
|
||||
self.server = HTTPServer(('0.0.0.0', self.port), HealthCheckHandler)
|
||||
self.thread = threading.Thread(target=self.server.serve_forever, daemon=True)
|
||||
self.thread.start()
|
||||
logging.info(f"Health check server started on port {self.port}")
|
||||
logging.info(f"Health check server started on 0.0.0.0:{self.port}")
|
||||
logging.info(f"Health check endpoints:")
|
||||
logging.info(f" - http://localhost:{self.port}/health")
|
||||
logging.info(f" - http://localhost:{self.port}/sensors")
|
||||
logging.info(f" - http://0.0.0.0:{self.port}/health")
|
||||
logging.info(f" - http://0.0.0.0:{self.port}/sensors")
|
||||
except Exception as e:
|
||||
logging.error(f"Failed to start health check server: {e}")
|
||||
raise e # Re-raise to make the issue visible
|
||||
|
||||
def stop(self):
|
||||
"""Stop the health check server"""
|
||||
|
Reference in New Issue
Block a user