From 380e9cf30ed8e7965c4e08a6f9b5ce3911955d7e Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Fri, 26 Feb 2021 00:40:13 +0100 Subject: [PATCH] Revert "Revert "DPL: switch to ws:// as default client for self hosted (#5535)" (#5561)" This reverts commit 97bf3184df201e7bbf65c808dd33166abd12ee96. --- Framework/Core/include/Framework/DriverInfo.h | 5 +++++ Framework/Core/src/DeviceSpecHelpers.cxx | 4 ++-- Framework/Core/src/runDataProcessing.cxx | 21 ++++++++++++------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Framework/Core/include/Framework/DriverInfo.h b/Framework/Core/include/Framework/DriverInfo.h index e98eabb22a2c4..c0fc305a974cd 100644 --- a/Framework/Core/include/Framework/DriverInfo.h +++ b/Framework/Core/include/Framework/DriverInfo.h @@ -145,6 +145,11 @@ struct DriverInfo { DeviceMetricsInfo metrics; /// Skip shared memory cleanup if set bool noSHMCleanup; + /// Default value for the --driver-client-backend. Notice that if we start from + /// the driver, the default backend will be the websocket one. On the other hand, + /// if the device is started standalone, the default becomes the old stdout:// so + /// that it works as it used to in AliECS. + std::string defaultDriverClient = "invalid"; }; struct DriverInfoHelper { diff --git a/Framework/Core/src/DeviceSpecHelpers.cxx b/Framework/Core/src/DeviceSpecHelpers.cxx index e166cc427a30f..21abb1711210d 100644 --- a/Framework/Core/src/DeviceSpecHelpers.cxx +++ b/Framework/Core/src/DeviceSpecHelpers.cxx @@ -1037,7 +1037,7 @@ void DeviceSpecHelpers::prepareArguments(bool defaultQuiet, bool defaultStopped, // has option --session been specified on the command line? bool haveSessionArg = false; using FilterFunctionT = std::function; - bool useDefaultWS = false; + bool useDefaultWS = true; // the filter function will forward command line arguments based on the option // definition passed to it. All options of the program option definition will be forwarded @@ -1110,7 +1110,7 @@ void DeviceSpecHelpers::prepareArguments(bool defaultQuiet, bool defaultStopped, } haveSessionArg = haveSessionArg || varmap.count("session") != 0; - useDefaultWS = useDefaultWS || (varmap.count("driver-client-backend") != 0) && varmap["driver-client-backend"].as() == "ws://"; + useDefaultWS = useDefaultWS && ((varmap.count("driver-client-backend") == 0) || varmap["driver-client-backend"].as() == "ws://"); for (const auto varit : varmap) { // find the option belonging to key, add if the option has been parsed diff --git a/Framework/Core/src/runDataProcessing.cxx b/Framework/Core/src/runDataProcessing.cxx index d50e75fcd6d8c..b65ab97657819 100644 --- a/Framework/Core/src/runDataProcessing.cxx +++ b/Framework/Core/src/runDataProcessing.cxx @@ -935,7 +935,10 @@ void doDefaultWorkflowTerminationHook() //LOG(INFO) << "Process " << getpid() << " is exiting."; } -int doChild(int argc, char** argv, ServiceRegistry& serviceRegistry, const o2::framework::DeviceSpec& spec, TerminationPolicy errorPolicy, +int doChild(int argc, char** argv, ServiceRegistry& serviceRegistry, + const o2::framework::DeviceSpec& spec, + TerminationPolicy errorPolicy, + std::string const& defaultDriverClient, uv_loop_t* loop) { fair::Logger::SetConsoleColor(false); @@ -946,13 +949,13 @@ int doChild(int argc, char** argv, ServiceRegistry& serviceRegistry, const o2::f // Populate options from the command line. Notice that only the options // declared in the workflow definition are allowed. - runner.AddHook([&spec](fair::mq::DeviceRunner& r) { + runner.AddHook([&spec, defaultDriverClient](fair::mq::DeviceRunner& r) { boost::program_options::options_description optsDesc; ConfigParamsHelper::populateBoostProgramOptions(optsDesc, spec.options, gHiddenDeviceOptions); - optsDesc.add_options()("monitoring-backend", bpo::value()->default_value("default"), "monitoring backend info") // - ("driver-client-backend", bpo::value()->default_value("stdout://"), "backend for device -> driver communicataon: stdout://: use stdout, ws://: use websockets") // - ("infologger-severity", bpo::value()->default_value(""), "minimum FairLogger severity to send to InfoLogger") // - ("configuration,cfg", bpo::value()->default_value("command-line"), "configuration backend") // + optsDesc.add_options()("monitoring-backend", bpo::value()->default_value("default"), "monitoring backend info") // + ("driver-client-backend", bpo::value()->default_value(defaultDriverClient), "backend for device -> driver communicataon: stdout://: use stdout, ws://: use websockets") // + ("infologger-severity", bpo::value()->default_value(""), "minimum FairLogger severity to send to InfoLogger") // + ("configuration,cfg", bpo::value()->default_value("command-line"), "configuration backend") // ("infologger-mode", bpo::value()->default_value(""), "INFOLOGGER_MODE override"); r.fConfig.AddToCmdLineOptions(optsDesc, true); }); @@ -1363,7 +1366,9 @@ int runStateMachine(DataProcessorSpecs const& workflow, if (spec.id == frameworkId) { return doChild(driverInfo.argc, driverInfo.argv, serviceRegistry, spec, - driverInfo.errorPolicy, loop); + driverInfo.errorPolicy, + driverInfo.defaultDriverClient, + loop); } } { @@ -2226,8 +2231,10 @@ int doMain(int argc, char** argv, o2::framework::WorkflowSpec const& workflow, if (varmap.count("id")) { frameworkId = varmap["id"].as(); driverInfo.uniqueWorkflowId = fmt::format("{}", getppid()); + driverInfo.defaultDriverClient = "stdout://"; } else { driverInfo.uniqueWorkflowId = fmt::format("{}", getpid()); + driverInfo.defaultDriverClient = "ws://"; } return runStateMachine(physicalWorkflow, currentWorkflow,