feat: add stream_enabled config to control ffmpeg pulling and optimize infer startup script
This commit is contained in:
@@ -17,6 +17,7 @@ type Config struct {
|
||||
MqttUser string `yaml:"mqtt_user"`
|
||||
MqttPass string `yaml:"mqtt_pass"`
|
||||
EdgeToken string `yaml:"edge_token"`
|
||||
StreamEnabled bool `yaml:"stream_enabled"`
|
||||
RTSPURLs []string `yaml:"rtsp_urls"`
|
||||
InferSocket string `yaml:"infer_socket"`
|
||||
InferFPS int `yaml:"infer_fps"`
|
||||
|
||||
@@ -64,6 +64,23 @@ func (sm *StreamManager) applyStreams(ctx context.Context, urls []string, fps in
|
||||
sm.mu.Lock()
|
||||
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)
|
||||
toRemove := map[string]*streamProcess{}
|
||||
for url, sp := range sm.processes {
|
||||
|
||||
12
start_infer.sh
Executable file
12
start_infer.sh
Executable 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
|
||||
Reference in New Issue
Block a user