Compare commits

..

4 Commits

Author SHA1 Message Date
hasslesstech bc0977588e [P] Add second agent in docker-compose.yaml
Component testing / Hub testing (push) Successful in 21s
Component testing / Store testing (push) Successful in 22s
Component testing / Integration smoke testing (push) Has been cancelled
2026-03-25 22:34:50 +02:00
hasslesstech 3d2b02c0c6 [P] Add GPS file selection to agent 2026-03-25 22:34:50 +02:00
hasslesstech e3b27bbd4c [P] Add TRACK_ID selection in MapView
Component testing / Hub testing (push) Successful in 27s
Component testing / Store testing (push) Successful in 24s
Component testing / Integration smoke testing (push) Failing after 14s
2026-03-25 22:34:15 +02:00
hasslesstech 987e968dd4 [P] Fix wrong row sending order
Component testing / Hub testing (push) Successful in 27s
Component testing / Store testing (push) Successful in 29s
Component testing / Integration smoke testing (push) Successful in 2m33s
2026-03-25 22:27:40 +02:00
5 changed files with 25 additions and 13 deletions
+3 -4
View File
@@ -1,18 +1,17 @@
import os import os
def try_parse(type, value: str): def try_parse(type, value: str):
try: try:
return type(value) return type(value)
except Exception: except Exception:
return None return None
USER_ID = try_parse(int, os.environ.get("USER_ID")) or 1
# MQTT config # MQTT config
MQTT_BROKER_HOST = os.environ.get("MQTT_BROKER_HOST") or "mqtt" MQTT_BROKER_HOST = os.environ.get("MQTT_BROKER_HOST") or "mqtt"
MQTT_BROKER_PORT = try_parse(int, os.environ.get("MQTT_BROKER_PORT")) or 1883 MQTT_BROKER_PORT = try_parse(int, os.environ.get("MQTT_BROKER_PORT")) or 1883
MQTT_TOPIC = os.environ.get("MQTT_TOPIC") or "agent" MQTT_TOPIC = os.environ.get("MQTT_TOPIC") or "agent"
# Delay for sending data to mqtt in seconds # Data-related config
USER_ID = try_parse(int, os.environ.get("USER_ID")) or 1
DELAY = try_parse(float, os.environ.get("DELAY")) or 1 DELAY = try_parse(float, os.environ.get("DELAY")) or 1
GPS_SOURCE = os.environ.get("GPS_SOURCE") or "data/gps.csv"
+1 -1
View File
@@ -42,7 +42,7 @@ def run():
# Prepare mqtt client # Prepare mqtt client
client = connect_mqtt(config.MQTT_BROKER_HOST, config.MQTT_BROKER_PORT) client = connect_mqtt(config.MQTT_BROKER_HOST, config.MQTT_BROKER_PORT)
# Prepare datasource # Prepare datasource
datasource = FileDatasource(16384.0, "data/accelerometer.csv", "data/gps.csv", "data/parking.csv") datasource = FileDatasource(16384.0, "data/accelerometer.csv", config.GPS_SOURCE, "data/parking.csv")
# Infinity publish data # Infinity publish data
publish(client, config.MQTT_TOPIC, datasource) publish(client, config.MQTT_TOPIC, datasource)
+20 -3
View File
@@ -14,8 +14,7 @@ services:
mqtt_network: mqtt_network:
fake_agent: agent1:
container_name: agent
build: build:
context: . context: .
dockerfile: agent/Dockerfile dockerfile: agent/Dockerfile
@@ -26,7 +25,25 @@ services:
MQTT_BROKER_HOST: "mqtt" MQTT_BROKER_HOST: "mqtt"
MQTT_BROKER_PORT: 1883 MQTT_BROKER_PORT: 1883
MQTT_TOPIC: "agent_data_topic" MQTT_TOPIC: "agent_data_topic"
DELAY: 0.1 DELAY: 1.2
USER_ID: 2
networks:
mqtt_network:
agent2:
build:
context: .
dockerfile: agent/Dockerfile
depends_on:
- mqtt
environment:
PYTHONUNBUFFERED: 1
MQTT_BROKER_HOST: "mqtt"
MQTT_BROKER_PORT: 1883
MQTT_TOPIC: "agent_data_topic"
GPS_SOURCE: "data/route2.csv"
DELAY: 1.0
USER_ID: 3
networks: networks:
mqtt_network: mqtt_network:
+1 -1
View File
@@ -45,7 +45,7 @@ async def websocket_endpoint(websocket: WebSocket, user_id: int):
try: try:
# send already available data # send already available data
r = processed_agent_data.select().order_by(processed_agent_data.c.timestamp) r = processed_agent_data.select()
stored_data = SessionLocal().execute(r).fetchall() stored_data = SessionLocal().execute(r).fetchall()
jsonable_data = [{c.name: getattr(i, c.name) for c in processed_agent_data.columns} for i in stored_data] jsonable_data = [{c.name: getattr(i, c.name) for c in processed_agent_data.columns} for i in stored_data]
-4
View File
@@ -1,5 +1,4 @@
import sys import sys
import os
print("Checking for dead containers...") print("Checking for dead containers...")
@@ -15,9 +14,6 @@ for i in statuses:
if not i[status_index:].startswith("Up "): if not i[status_index:].startswith("Up "):
service_name = i[name_index:] service_name = i[name_index:]
print(f"Crash detected in {service_name}") print(f"Crash detected in {service_name}")
print(f"docker logs for the container:\n")
os.system(f"docker logs {i.split(' ')[0]}")
print()
exit_code = 1 exit_code = 1
sys.exit(exit_code) sys.exit(exit_code)