artdaq  v3_12_02
ArtdaqGlobalsService_service.cc
1 #define TRACE_NAME "ArtdaqGlobalsService"
2 
3 #include <cstdint>
4 #include <memory>
5 
6 #include "art/Framework/Services/Registry/ServiceHandle.h"
7 #include "artdaq-core/Utilities/ExceptionHandler.hh"
8 #include "artdaq/ArtModules/ArtdaqGlobalsService.h"
9 
10 #include "artdaq/DAQdata/Globals.hh"
11 
12 #define build_key(seed) ((seed) + ((GetPartitionNumber() + 1) << 16) + (getppid() & 0xFFFF))
13 
14 static fhicl::ParameterSet empty_pset;
15 
16 ArtdaqGlobalsService::ArtdaqGlobalsService(fhicl::ParameterSet const& pset, art::ActivityRegistry& /*unused*/)
17 {
18  TLOG(TLVL_DEBUG + 33) << "ArtdaqGlobalsService CONSTRUCTOR";
19 
20  char const* artapp_env = getenv("ARTDAQ_APPLICATION_NAME");
21  std::string artapp_str;
22  if (artapp_env != nullptr)
23  {
24  artapp_str = std::string(artapp_env) + "_";
25  }
26 
27  TLOG(TLVL_DEBUG + 33) << "Setting app_name";
28 
29  artapp_env = getenv("ARTDAQ_RANK");
30  if (artapp_env != nullptr && my_rank < 0)
31  {
32  TLOG(TLVL_DEBUG + 33) << "Setting rank from envrionment";
33  my_rank = strtol(artapp_env, nullptr, 10);
34  app_name = artapp_str + "art" + std::string(artapp_env);
35  }
36  else
37  {
38  TLOG(TLVL_DEBUG + 33) << "Setting default rank and name";
39  my_rank = -1;
40  app_name = artapp_str + "art";
41  }
42 
43  try
44  {
45  if (metricMan)
46  {
47  metricMan->initialize(pset.get<fhicl::ParameterSet>("metrics", fhicl::ParameterSet()), app_name);
48  metricMan->do_start();
49  }
50  }
51  catch (...)
52  {
53  artdaq::ExceptionHandler(artdaq::ExceptionHandlerRethrow::no, "Error loading metrics in ArtdaqGlobalsService()");
54  }
55 
56  TLOG(TLVL_INFO) << "app_name is " << app_name << ", rank " << my_rank;
57 }
58 
60 {
62 }
63 
64 DEFINE_ART_SERVICE_INTERFACE_IMPL(ArtdaqGlobalsService, ArtdaqSharedMemoryServiceInterface)
Interface for ArtdaqSharedMemoryService. This interface is declared to art as part of the required re...
virtual ~ArtdaqGlobalsService()
ArtdaqGlobalsService Destructor. Calls disconnect().
static void CleanUpGlobals()
Clean up statically-allocated Manager class instances.
Definition: Globals.hh:156
ArtdaqGlobalsService(fhicl::ParameterSet const &pset, art::ActivityRegistry &)
ArtdaqGlobalsService Constructor.
ArtdaqGlobalsService extends ArtdaqSharedMemoryServiceInterface. It manages the artdaq Global varaibl...