From c84727c8ec0f99d66d1ad7d4716de79b6235d4d1 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Thu, 11 Sep 2025 15:37:32 +0200 Subject: Add runtime linkage-set reload --- src/DabMux.cpp | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) (limited to 'src/DabMux.cpp') diff --git a/src/DabMux.cpp b/src/DabMux.cpp index 0066629..7b5f5d6 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -31,8 +31,6 @@ #include #include -#include -#include #include #include #include @@ -132,12 +130,13 @@ int main(int argc, char *argv[]) } int returnCode = 0; - ptree pt; std::vector > outputs; try { string conf_file = ""; + DabMultiplexerConfig mux_conf; + if (argc == 2) { // Assume the only argument is a config file conf_file = argv[1]; @@ -154,8 +153,7 @@ int main(int argc, char *argv[]) } conf_file = argv[2]; - - read_info(conf_file, pt); + mux_conf.read(conf_file); } catch (runtime_error &e) { throw MuxInitException(e.what()); @@ -168,23 +166,18 @@ int main(int argc, char *argv[]) } try { - if (stringEndsWith(conf_file, ".json")) { - read_json(conf_file, pt); - } - else { - read_info(conf_file, pt); - } + mux_conf.read(conf_file); } catch (runtime_error &e) { throw MuxInitException(e.what()); } /* Enable Logging to syslog conditionally */ - if (pt.get("general.syslog", false)) { + if (mux_conf.pt.get("general.syslog", false)) { etiLog.register_backend(std::make_shared()); } - const auto startupcheck = pt.get("general.startupcheck", ""); + const auto startupcheck = mux_conf.pt.get("general.startupcheck", ""); if (not startupcheck.empty()) { etiLog.level(info) << "Running startup check '" << startupcheck << "'"; int wstatus = system(startupcheck.c_str()); @@ -204,26 +197,26 @@ int main(int argc, char *argv[]) } } - int mgmtserverport = pt.get("general.managementport", - pt.get("general.statsserverport", 0) ); + int mgmtserverport = mux_conf.pt.get("general.managementport", + mux_conf.pt.get("general.statsserverport", 0) ); /* Management: stats and config server */ get_mgmt_server().open(mgmtserverport); /************** READ REMOTE CONTROL PARAMETERS *************/ - int telnetport = pt.get("remotecontrol.telnetport", 0); + int telnetport = mux_conf.pt.get("remotecontrol.telnetport", 0); if (telnetport != 0) { auto rc = std::make_shared(telnetport); rcs.add_controller(rc); } - auto zmqendpoint = pt.get("remotecontrol.zmqendpoint", ""); + auto zmqendpoint = mux_conf.pt.get("remotecontrol.zmqendpoint", ""); if (not zmqendpoint.empty()) { auto rc = std::make_shared(zmqendpoint); rcs.add_controller(rc); } - DabMultiplexer mux(pt); + DabMultiplexer mux(mux_conf); etiLog.level(info) << PACKAGE_NAME << " " << @@ -240,7 +233,7 @@ int main(int argc, char *argv[]) /******************** READ OUTPUT PARAMETERS ***************/ set all_output_names; bool output_require_tai_clock = false; - ptree pt_outputs = pt.get_child("outputs"); + ptree pt_outputs = mux_conf.pt.get_child("outputs"); for (auto ptree_pair : pt_outputs) { string outputuid = ptree_pair.first; @@ -444,7 +437,6 @@ int main(int argc, char *argv[]) } outputs.push_back(output); - } } @@ -464,7 +456,7 @@ int main(int argc, char *argv[]) edi_conf.print(); } - size_t limit = pt.get("general.nbframes", 0); + const size_t limit = mux_conf.pt.get("general.nbframes", 0); etiLog.level(info) << "Start loop"; /* Each iteration of the main loop creates one ETI frame */ @@ -473,6 +465,7 @@ int main(int argc, char *argv[]) mux.mux_frame(outputs); if (limit && currentFrame >= limit) { + etiLog.level(info) << "Max number of ETI frames reached: " << currentFrame; break; } @@ -491,17 +484,12 @@ int main(int argc, char *argv[]) mgmt_server.restart(); } - mgmt_server.update_ptree(pt); + mgmt_server.update_ptree(mux_conf.pt); } } - - if (limit) { - etiLog.level(info) << "Max number of ETI frames reached: " << currentFrame; - } } catch (const MuxInitException& except) { - etiLog.level(error) << "Multiplex initialisation aborted: " << - except.what(); + etiLog.level(error) << "Multiplex initialisation aborted: " << except.what(); returnCode = 1; } catch (const std::invalid_argument& except) { -- cgit v1.2.3