diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-02-24 10:23:38 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-02-24 10:23:38 +0100 |
commit | 4516c0079dabc46d6787eeb037fd7b054ce8c81b (patch) | |
tree | c025da511600d80ff6045ef317aed8912f738039 /src/odr-sourcecompanion.cpp | |
parent | c8c5e2f42ebab4e77c25a3a8c7539c86aafe3790 (diff) | |
download | ODR-SourceCompanion-4516c0079dabc46d6787eeb037fd7b054ce8c81b.tar.gz ODR-SourceCompanion-4516c0079dabc46d6787eeb037fd7b054ce8c81b.tar.bz2 ODR-SourceCompanion-4516c0079dabc46d6787eeb037fd7b054ce8c81b.zip |
Add startupcheck
Diffstat (limited to 'src/odr-sourcecompanion.cpp')
-rw-r--r-- | src/odr-sourcecompanion.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/odr-sourcecompanion.cpp b/src/odr-sourcecompanion.cpp index d41873b..df1d514 100644 --- a/src/odr-sourcecompanion.cpp +++ b/src/odr-sourcecompanion.cpp @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------ - * Copyright (C) 2020 Matthias P. Braendli + * Copyright (C) 2021 Matthias P. Braendli * Copyright (C) 2017 AVT GmbH - Fabien Vercasson * Copyright (C) 2011 Martin Storsjo * @@ -96,6 +96,7 @@ void usage(const char* name) { " -e, --edi=URI EDI output uri, (e.g. 'tcp://localhost:7000')\n" " -T, --timestamp-delay=DELAY_MS Enabled timestamps in EDI (requires TAI clock bulletin download) and\n" " add a delay (in milliseconds) to the timestamps carried in EDI\n" + " --startup-check=SCRIPT_PATH Before starting, run the given script, and only start if it returns 0.\n" " -k, --secret-key=FILE Enable ZMQ encryption with the given secret key.\n" " -p, --pad=BYTES Set PAD size in bytes.\n" " -P, --pad-socket=IDENTIFIER Use the given identifier to communicate with ODR-PadEnc.\n" @@ -162,6 +163,7 @@ int main(int argc, char *argv[]) {"rate", required_argument, 0, 'r'}, {"stats", required_argument, 0, 'S'}, {"secret-key", required_argument, 0, 'k'}, + {"startup-check", required_argument, 0, 10 }, {"identifier", required_argument, 0, 3 }, {"input-uri", required_argument, 0, 'I'}, {"control-uri", required_argument, 0, 6 }, @@ -206,6 +208,7 @@ int main(int argc, char *argv[]) int bitrate = 0; int channels = 2; int sample_rate = 48000; + string startupcheck; int ch = 0; int index; while(ch != -1) { @@ -286,6 +289,9 @@ int main(int argc, char *argv[]) case 9: avt_jitterBufferSize = stoi(optarg); break; + case 10: // --startup-check + startupcheck = optarg; + break; case '?': case 'h': usage(argv[0]); @@ -303,6 +309,25 @@ int main(int argc, char *argv[]) return 1; } + 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; + } + } + shared_ptr<Output::ZMQ> zmq_output; Output::EDI edi_output; |