00001 #include <iostream>
00002 #include <boost/program_options.hpp>
00003 #include <boost/lexical_cast.hpp>
00004 #include "artdaq/Application/TaskType.hh"
00005 #include "artdaq/DAQdata/Globals.hh"
00006 #include "artdaq/Application/DispatcherApp.hh"
00007 #include "artdaq/ExternalComms/MakeCommanderPlugin.hh"
00008 #include "artdaq/Application/LoadParameterSet.hh"
00009 #include "artdaq-mpich-plugin/Application/MPISentry.hh"
00010 #include "artdaq/BuildInfo/GetPackageBuildInfo.hh"
00011 #include "cetlib_except/exception.h"
00012
00013 int main(int argc, char* argv[])
00014 {
00015
00016
00017 int const wanted_threading_level{ MPI_THREAD_FUNNELED };
00018
00019 MPI_Comm local_group_comm;
00020 std::unique_ptr<artdaq::MPISentry> mpiSentry;
00021
00022 try
00023 {
00024 mpiSentry.reset(new artdaq::MPISentry(&argc, &argv, wanted_threading_level, artdaq::TaskType::DispatcherTask, local_group_comm));
00025 }
00026 catch (cet::exception& errormsg)
00027 {
00028 TLOG_ERROR("DispatcherMain") << errormsg ;
00029 TLOG_ERROR("DispatcherMain") << "MPISentry error encountered in DispatcherMain; exiting..." ;
00030 throw errormsg;
00031 }
00032
00033 struct Config
00034 {
00035 fhicl::TableFragment<artdaq::CommanderInterface::Config> commander_config;
00036 fhicl::Atom<std::string> application_name{ fhicl::Name{ "application_name" }, fhicl::Comment{ "Name of the application for metrics and logging" }, "Dispatcher" };
00037 fhicl::TableFragment<artdaq::PortManager::Config> portsConfig;
00038 };
00039
00040 fhicl::ParameterSet config = LoadParameterSet<Config>(argc, argv, "DispatcherMain", "This is the Dispatcher's main executable (MPI version)");
00041 app_name = config.get<std::string>("application_name", "Dispatcher");
00042 portMan->UpdateConfiguration(config);
00043 std::string mf_app_name = artdaq::setMsgFacAppName(app_name, config.get<int>("id"));
00044 artdaq::configureMessageFacility(mf_app_name.c_str());
00045 TLOG_DEBUG(app_name + "Main") << "Setting application name to " << mf_app_name ;
00046
00047
00048 if (config.has_key("partition_number"))
00049 {
00050 artdaq::Globals::partition_number_ = config.get<int>("partition_number");
00051 }
00052 TLOG_DEBUG(app_name + "Main") << "Setting partition number to " << artdaq::Globals::partition_number_;
00053
00054 TLOG_INFO(app_name + "Main") << "artdaq version " <<
00055 artdaq::GetPackageBuildInfo::getPackageBuildInfo().getPackageVersion()
00056 << ", built " <<
00057 artdaq::GetPackageBuildInfo::getPackageBuildInfo().getBuildTimestamp() ;
00058
00059
00060 my_rank = mpiSentry->rank();
00061 artdaq::DispatcherApp disp_app;
00062
00063 auto commander = artdaq::MakeCommanderPlugin(config, disp_app);
00064 TLOG_INFO(app_name + "Main") << "Running Commmander Server" ;
00065 commander->run_server();
00066 artdaq::Globals::CleanUpGlobals();
00067 TLOG_INFO(app_name + "Main") << "Commandable Server ended, exiting..." ;
00068 }