feat: add stream_enabled config to control ffmpeg pulling and optimize infer startup script

This commit is contained in:
2026-05-09 09:48:43 +08:00
parent 97a77d4745
commit 966ef512ab
3 changed files with 30 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ type Config struct {
MqttUser string `yaml:"mqtt_user"` MqttUser string `yaml:"mqtt_user"`
MqttPass string `yaml:"mqtt_pass"` MqttPass string `yaml:"mqtt_pass"`
EdgeToken string `yaml:"edge_token"` EdgeToken string `yaml:"edge_token"`
StreamEnabled bool `yaml:"stream_enabled"`
RTSPURLs []string `yaml:"rtsp_urls"` RTSPURLs []string `yaml:"rtsp_urls"`
InferSocket string `yaml:"infer_socket"` InferSocket string `yaml:"infer_socket"`
InferFPS int `yaml:"infer_fps"` InferFPS int `yaml:"infer_fps"`

View File

@@ -64,6 +64,23 @@ func (sm *StreamManager) applyStreams(ctx context.Context, urls []string, fps in
sm.mu.Lock() sm.mu.Lock()
defer sm.mu.Unlock() defer sm.mu.Unlock()
// Stream enabled check
enabled := true
if sm.cfg != nil && !sm.cfg.StreamEnabled {
enabled = false
}
// If disabled, stop all streams and return
if !enabled {
log.Println("stream: disabled by config, stopping all")
for url, sp := range sm.processes {
log.Printf("stream: stopping %s", url)
sm.stopProcess(sp)
delete(sm.processes, url)
}
return
}
// Identify URLs to remove (present in sm.processes but not in new urls) // Identify URLs to remove (present in sm.processes but not in new urls)
toRemove := map[string]*streamProcess{} toRemove := map[string]*streamProcess{}
for url, sp := range sm.processes { for url, sp := range sm.processes {

12
start_infer.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
exec >> /tmp/infer-server-systemd.log 2>&1
echo "=== infer-server starting $(date) ==="
export LD_LIBRARY_PATH=/usr/local/Ascend/ascend-toolkit/latest/arm64-linux/lib64:/usr/local/Ascend/driver/lib64:/usr/local/Ascend/ascend-toolkit/latest/arm64-linux/lib64/plugin/opskernel
export ASCEND_OPP_PATH=/usr/local/Ascend/ascend-toolkit/latest/arm64-linux/opp
export PYTHONPATH=/usr/local/Ascend/ascend-toolkit/latest/python/site-packages:$PYTHONPATH
export PATH=/usr/local/miniconda3/bin:$PATH
cd /root/AI-tianyan
echo "PYTHONPATH=$PYTHONPATH"
/usr/local/miniconda3/bin/python3 -c "import acl; print('acl OK:', acl.__file__)" 2>&1
echo "--- launching server ---"
exec /usr/local/miniconda3/bin/python3 /root/AI-tianyan/python/infer_server.py