Fix: InfluxDB async write + Grafana Org rename + GeoServer workspace
This commit is contained in:
11
simulator.py
11
simulator.py
@@ -748,9 +748,11 @@ def publish_openremote(sid: str, sensor: dict, values: dict) -> bool:
|
|||||||
return _or_put(asset_id, payload)
|
return _or_put(asset_id, payload)
|
||||||
|
|
||||||
def publish_influx(sid: str, sensor: dict, values: dict) -> bool:
|
def publish_influx(sid: str, sensor: dict, values: dict) -> bool:
|
||||||
"""Write sensor data to InfluxDB."""
|
"""Write sensor data to InfluxDB (async, non-blocking)."""
|
||||||
if not _influx_write_api:
|
if not _influx_write_api:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _write_async():
|
||||||
try:
|
try:
|
||||||
stype = sensor["type"]
|
stype = sensor["type"]
|
||||||
lat = sensor.get("lat", BASE_LAT)
|
lat = sensor.get("lat", BASE_LAT)
|
||||||
@@ -770,10 +772,13 @@ def publish_influx(sid: str, sensor: dict, values: dict) -> bool:
|
|||||||
if points:
|
if points:
|
||||||
_influx_write_api.write(bucket=INFLUX_BUCKET, record=points)
|
_influx_write_api.write(bucket=INFLUX_BUCKET, record=points)
|
||||||
print(f" 📈 InfluxDB: {len(points)} points written")
|
print(f" 📈 InfluxDB: {len(points)} points written")
|
||||||
return True
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f" ⚠️ InfluxDB → {e}")
|
print(f" ⚠️ InfluxDB → {e}")
|
||||||
return False
|
|
||||||
|
# Exécution asynchrone (non-bloquante)
|
||||||
|
t = threading.Thread(target=_write_async, daemon=True)
|
||||||
|
t.start()
|
||||||
|
return True
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("╔══════════════════════════════════════════════════╗")
|
print("╔══════════════════════════════════════════════════╗")
|
||||||
|
|||||||
Reference in New Issue
Block a user