diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-11-25 16:20:27 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-11-25 16:20:27 +0100 |
commit | e845a4188b93a31445a780ae11f33286420cb038 (patch) | |
tree | 31aecf769c262c1ac639b71bfd381c7e2122f51c | |
parent | 939abd61fc10cb8df2ecdc6d92764bb3ea5b41a7 (diff) | |
download | dabmux-e845a4188b93a31445a780ae11f33286420cb038.tar.gz dabmux-e845a4188b93a31445a780ae11f33286420cb038.tar.bz2 dabmux-e845a4188b93a31445a780ae11f33286420cb038.zip |
Add startupcheck functionality
-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) ); |