Belle II Software  release-08-01-10
rf_eventprocessor.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 //#define DESY
10 
11 #include "daq/rfarm/manager/RFEventProcessor.h"
12 #include "daq/rfarm/manager/RFNSM.h"
13 
14 #include <unistd.h>
15 
16 #include <csignal>
17 #include <cstring>
18 
19 using namespace std;
20 using namespace Belle2;
21 
22 static RFEventProcessor* evproc = NULL;
23 
24 extern "C" void sighandler(int /*sig*/)
25 {
26  printf("SIGTERM handler here\n");
27  evproc->cleanup();
28 }
29 
30 int main(int argc, char** argv)
31 {
32  if (argc < 2) return 1;
33 
34  RFConf conf(argv[1]);
35 
36  // RFEventProcessor* evproc = new RFEventProcessor(argv[1]);
37  evproc = new RFEventProcessor(argv[1]);
38 
39  char nodename[256 + 4];
40  strcpy(nodename, "evp_");
41 #ifndef DESY
42  gethostname(&nodename[4], sizeof(nodename) - 4);
43 #else
44  // Special treatment for DESY test nodes!!
45  char hostnamebuf[256];
46  gethostname(hostnamebuf, sizeof(hostnamebuf));
47  strcat(&nodename[4], &hostnamebuf[6]);
48  int lend = strlen(nodename);
49  nodename[lend + 1] = (char)0;
50  nodename[lend] = nodename[lend - 1];
51  strncpy(&nodename[lend - 1], "0", 1);
52  printf("DESY node name = %s\n", nodename);
53  // End of DESY special treatment
54 #endif
55 
56  signal(SIGINT, sighandler);
57  signal(SIGTERM, sighandler);
58 
59  RFNSM nsm(nodename, evproc);
60  nsm.AllocMem(conf.getconf("system", "nsmdata"));
61  evproc->SetNodeInfo(nsm.GetNodeInfo());
62 
63  evproc->server();
64 
65 }
Abstract base class for different kinds of events.
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:91