Files
DMF-Studio/engine/src/main.cpp
T
Johanness 4b50f49172 chore: phase 1 cleanup — proper shutdown, flow resource cleanup, test fix
- node_runner: track all readers/writers in flow_resources vector,
  release them via mxlReleaseFlowWriter/mxlReleaseFlowReader before
  destroying the MXL instance (fixes 'leaked flow writer' warning)
- node_runner: remove_writer/remove_reader commands now also release
  the MXL flow resources, not just reset the node's optional<>
- engine: call process_manager.stop_all(graph) on shutdown to kill
  child node processes (prevents orphaned passthrough processes)
- graph: add get_node_mut() for process_manager to update node state
- process_manager: implement stop_all(Graph&) that SIGTERMs all
  running node processes
- passthrough: reduce logging to first-grain and realign-once only
- tests: update flow format assertion to match NMOS
  (urn:x-nmos:format:video instead of video/v210)
2026-05-26 23:04:16 +03:00

58 lines
1.7 KiB
C++

#include <dmf-engine/api_server.hpp>
#include <dmf-engine/graph.hpp>
#include <dmf-engine/flow_manager.hpp>
#include <dmf-engine/process_manager.hpp>
#include <dmf-engine/node_control_client.hpp>
#include <spdlog/spdlog.h>
#include <csignal>
#include <atomic>
static std::atomic<bool> g_running{true};
static void signal_handler(int /*signum*/) {
g_running = false;
}
int main(int argc, char* argv[]) {
uint16_t port = 8080;
std::string mxl_domain = "/dev/shm/mxl";
for (int i = 1; i < argc; ++i) {
std::string arg = argv[i];
if ((arg == "--port" || arg == "-p") && i + 1 < argc) {
port = static_cast<uint16_t>(std::stoi(argv[++i]));
} else if ((arg == "--mxl-domain" || arg == "-d") && i + 1 < argc) {
mxl_domain = argv[++i];
} else if (arg == "--help" || arg == "-h") {
spdlog::info("Usage: dmf-studio-engine [options]");
spdlog::info(" --port, -p API server port (default: 8080)");
spdlog::info(" --mxl-domain, -d MXL domain path (default: /dev/shm/mxl)");
return 0;
}
}
std::signal(SIGINT, signal_handler);
std::signal(SIGTERM, signal_handler);
spdlog::info("DMF Studio Engine starting on port {}", port);
dmf_engine::Graph graph;
dmf_engine::FlowManager flow_manager;
dmf_engine::ProcessManager process_manager;
dmf_engine::NodeControlClient control_client;
dmf_engine::ApiServer api_server(port, graph, flow_manager, process_manager, control_client, mxl_domain);
spdlog::info("DMF Studio Engine ready");
while (g_running) {
api_server.poll(100);
}
spdlog::info("DMF Studio Engine shutting down");
process_manager.stop_all(graph);
return 0;
}