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 };
00038
00039 fhicl::ParameterSet config = LoadParameterSet<Config>(argc, argv, "DispatcherMain", "This is the Dispatcher's main executable (MPI version)");
00040 app_name = config.get<std::string>("application_name", "Dispatcher");
00041 std::string mf_app_name = artdaq::setMsgFacAppName(app_name, config.get<int>("id"));
00042 artdaq::configureMessageFacility(mf_app_name.c_str());
00043 TLOG_DEBUG(app_name + "Main") << "Setting application name to " << mf_app_name ;
00044
00045
00046 if (config.has_key("partition_number"))
00047 {
00048 artdaq::Globals::partition_number_ = config.get<int>("partition_number");
00049 }
00050 TLOG_DEBUG(app_name + "Main") << "Setting partition number to " << artdaq::Globals::partition_number_;
00051
00052 TLOG_INFO(app_name + "Main") << "artdaq version " <<
00053 artdaq::GetPackageBuildInfo::getPackageBuildInfo().getPackageVersion()
00054 << ", built " <<
00055 artdaq::GetPackageBuildInfo::getPackageBuildInfo().getBuildTimestamp() ;
00056
00057
00058 my_rank = mpiSentry->rank();
00059 artdaq::DispatcherApp disp_app;
00060
00061 auto commander = artdaq::MakeCommanderPlugin(config, disp_app);
00062 TLOG_INFO(app_name + "Main") << "Running Commmander Server" ;
00063 commander->run_server();
00064 TLOG_INFO(app_name + "Main") << "Commandable Server ended, exiting..." ;
00065 }