feat: add dynamic config reload, unique device identity (UUID), and MQTT support

- New StreamManager for dynamic RTSP/FLV stream lifecycle
- Dynamic worker scaling for inference
- Device UUID generation and persistence
- Telegraf config and NPU monitoring scripts
- .gitignore for build artifacts
This commit is contained in:
2026-05-08 16:26:10 +08:00
parent 2e7245d62e
commit 6e88d2392f
12 changed files with 433 additions and 70 deletions

View File

@@ -21,13 +21,14 @@ func main() {
flag.Parse()
cfg := config.Load(*cfgPath)
log.Printf("edge-agent start id=%s cloud=%s", cfg.EdgeID, cfg.CloudURL)
log.Printf("edge-agent start id=%s uuid=%s cloud=%s mqtt=%s",
cfg.EdgeID, cfg.GetDeviceIdentity(), cfg.CloudURL, cfg.MqttBroker)
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer cancel()
frames := make(chan stream.Frame, 50)
events := make(chan event.SuspectedEvent, 200)
frames := make(chan stream.Frame, 100)
events := make(chan event.SuspectedEvent, 500)
var wg sync.WaitGroup
run := func(fn func(context.Context)) {
@@ -38,11 +39,23 @@ func main() {
}()
}
run(stream.NewIngestor(cfg, frames).Run)
run(infer.NewClient(cfg, frames, events).Run)
// 1. Cloud Communication
mqttMgr := control.NewMqttManager(cfg)
run(mqttMgr.Run)
// 2. Stream Ingestion (Dynamic)
run(stream.NewStreamManager(cfg, frames, mqttMgr.GetUpdates()).Run)
// 3. Inference (Dynamic Workers)
run(infer.NewClient(cfg, frames, events, mqttMgr.GetUpdates()).Run)
// 4. Event Upload
run(event.NewUploader(cfg, events).Run)
// 5. Heartbeat
run(control.NewHeartbeat(cfg).Run)
run(control.NewConfigAgent(cfg).Run)
// 6. OTA Update
run(control.NewOTAAgent(cfg).Run)
wg.Wait()