artdaq  v3_00_01
DispatcherMain.cc
1 #include <iostream>
2 #include <boost/program_options.hpp>
3 #include <boost/lexical_cast.hpp>
4 #include "artdaq/Application/TaskType.hh"
5 #include "artdaq/DAQdata/Globals.hh"
6 #include "artdaq/Application/DispatcherApp.hh"
7 #include "artdaq/ExternalComms/MakeCommanderPlugin.hh"
8 #include "artdaq/Application/LoadParameterSet.hh"
9 #include "artdaq/Application/MPI2/MPISentry.hh"
11 #include "artdaq/BuildInfo/GetPackageBuildInfo.hh"
12 #include "cetlib_except/exception.h"
13 
14 int main(int argc, char* argv[])
15 {
16  // initialization
17 
18  int const wanted_threading_level{ MPI_THREAD_FUNNELED };
19 
20  MPI_Comm local_group_comm;
21  std::unique_ptr<artdaq::MPISentry> mpiSentry;
22 
23  try
24  {
25  mpiSentry.reset(new artdaq::MPISentry(&argc, &argv, wanted_threading_level, artdaq::TaskType::AggregatorTask, local_group_comm));
26  }
27  catch (cet::exception& errormsg)
28  {
29  TLOG_ERROR("DispatcherMain") << errormsg << TLOG_ENDL;
30  TLOG_ERROR("DispatcherMain") << "MPISentry error encountered in DispatcherMain; exiting..." << TLOG_ENDL;
31  throw errormsg;
32  }
33 
34  fhicl::ParameterSet config = LoadParameterSet(argc, argv);
35  app_name = config.get<std::string>("application_name", "Dispatcher");
36  std::string mf_app_name = artdaq::setMsgFacAppName(app_name, config.get<int>("id"));
37  artdaq::configureMessageFacility(mf_app_name.c_str());
38  TLOG_DEBUG(app_name + "Main") << "Setting application name to " << mf_app_name << TLOG_ENDL;
39 
40 
41  TLOG_INFO(app_name + "Main") << "artdaq version " <<
43  << ", built " <<
44  artdaq::GetPackageBuildInfo::getPackageBuildInfo().getBuildTimestamp() << TLOG_ENDL;
45 
46  // create the DispatcherApp
47  artdaq::DispatcherApp disp_app(mpiSentry->rank(), app_name);
48 
49  auto commander = artdaq::MakeCommanderPlugin(config, disp_app);
50  TLOG_INFO(app_name + "Main") << "Running Commmander Server" << TLOG_ENDL;
51  commander->run_server();
52  TLOG_INFO(app_name + "Main") << "Commandable Server ended, exiting..." << TLOG_ENDL;
53 }
DispatcherApp is an artdaq::Commandable derived class which controls the DispatcherCore.
The MPISentry class initializes and finalizes the MPI context that the artdaq applciations run in...
Definition: MPISentry.hh:15
int rank() const
Get the MPI rank of the application.
Definition: MPISentry.cc:113
static artdaq::PackageBuildInfo getPackageBuildInfo()
Gets the version number and build timestmap for artdaq.
std::unique_ptr< artdaq::CommanderInterface > MakeCommanderPlugin(const fhicl::ParameterSet &commander_pset, artdaq::Commandable &commandable)
Load a CommanderInterface plugin.