From fa56cc6eeec440db0340971b8038838c890c4901 Mon Sep 17 00:00:00 2001 From: cxh Date: Fri, 17 Oct 2025 15:29:38 +0800 Subject: [PATCH] 1 --- src/main.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1135860..59ca81f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,7 +22,7 @@ static void signal_handler(int signum) int main() { - // 安装信号处理器 + // ---------- 信号处理 ---------- struct sigaction sa{}; sa.sa_handler = signal_handler; sigemptyset(&sa.sa_mask); @@ -31,9 +31,9 @@ int main() sigaction(SIGTERM, &sa, nullptr); signal(SIGPIPE, SIG_IGN); - // 初始化日志 + // ---------- 初始化日志 ---------- Logger::set_log_to_file(get_executable_dir_file_path("app.log")); - LOG_INFO("[MAIN] Application starting..."); + LOG_INFO("[MAIN] ===== Vehicle Video Service Starting ====="); try { @@ -47,8 +47,11 @@ int main() return -1; } - // 初始化 GStreamer + // ---------- 初始化 GStreamer ---------- RTMPManager::init(); + + // ---------- 自动推流(8 路录像守护) ---------- + LOG_INFO("[MAIN] Starting all record streams..."); RTMPManager::start_all_record_streams(); // 启动 MQTT 线程 @@ -70,18 +73,16 @@ int main() // 主循环,仅等待退出信号 while (g_running.load(std::memory_order_relaxed)) std::this_thread::sleep_for(std::chrono::milliseconds(200)); - LOG_INFO("[MAIN] Shutdown requested. Cleaning up..."); - - // 停止所有 RTMP 流 + // ---------- 退出清理 ---------- + LOG_INFO("[MAIN] Shutdown requested. Stopping RTMP streams..."); RTMPManager::stop_all(); - // 等待 MQTT 线程退出 if (mqtt_thread.joinable()) { mqtt_thread.join(); LOG_INFO("[MAIN] MQTT thread joined."); } - LOG_INFO("[MAIN] Application exited cleanly."); + LOG_INFO("[MAIN] ===== Vehicle Video Service Exited Cleanly ====="); return 0; }