1
This commit is contained in:
parent
118b727f51
commit
fa56cc6eee
19
src/main.cpp
19
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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user