diff options
-rw-r--r-- | doc/example.mux | 6 | ||||
-rw-r--r-- | src/DabMux.cpp | 20 |
2 files changed, 26 insertions, 0 deletions
diff --git a/doc/example.mux b/doc/example.mux index be45344..83dbfbb 100644 --- a/doc/example.mux +++ b/doc/example.mux @@ -65,6 +65,12 @@ general { ; If the port is zero, or the line commented, the server ; is not started. managementport 12720 + + ; At startup, run the command and abort if is it not returning 0. + ; This may be a script. Useful for checking if the NTP client on your + ; system has had time to setup the clock. + ;startupcheck "chronyc waitsync 10 0.01" + ;startupcheck "ntp-wait -fv" } remotecontrol { diff --git a/src/DabMux.cpp b/src/DabMux.cpp index 3ee57c0..de0c362 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -239,6 +239,26 @@ int main(int argc, char *argv[]) etiLog.register_backend(std::make_shared<LogToSyslog>()); } + const auto startupcheck = pt.get<string>("general.startupcheck", ""); + if (not startupcheck.empty()) { + etiLog.level(info) << "Running startup check '" << startupcheck << "'"; + int wstatus = system(startupcheck.c_str()); + + if (WIFEXITED(wstatus)) { + if (WEXITSTATUS(wstatus) == 0) { + etiLog.level(info) << "Startup check ok"; + } + else { + etiLog.level(error) << "Startup check failed, returned " << WEXITSTATUS(wstatus); + return 1; + } + } + else { + etiLog.level(error) << "Startup check failed, child didn't terminate normally"; + return 1; + } + } + int mgmtserverport = pt.get<int>("general.managementport", pt.get<int>("general.statsserverport", 0) ); |