9 #include "daq/rfarm/manager/RFDqmServer.h"
12 #include <sys/types.h>
21 RFDqmServer::RFDqmServer(
string conffile)
24 m_conf =
new RFConf(conffile.c_str());
25 char* nodename = m_conf->getconf(
"dqmserver",
"nodename");
30 string execdir = string(m_conf->getconf(
"system",
"execdir_base")) +
"/dqmserver";
32 mkdir(execdir.c_str(), 0755);
33 chdir(execdir.c_str());
39 m_log =
new RFLogManager(nodename, m_conf->getconf(
"system",
"lognode"));
42 RFDqmServer::~RFDqmServer()
54 char* dqmserver = m_conf->getconf(
"dqmserver",
"script");
55 char* port = m_conf->getconf(
"dqmserver",
"port");
56 char* mapfile = m_conf->getconf(
"dqmserver",
"mapfile");
58 m_pid_dqm = m_proc->Execute(dqmserver, port, mapfile);
61 char* relayhost = m_conf->getconf(
"dqmserver",
"historelay",
"host");
62 char* relayport = m_conf->getconf(
"dqmserver",
"historelay",
"port");
63 char* hrelay = m_conf->getconf(
"dqmserver",
"historelay",
"script");
64 char* interval = m_conf->getconf(
"dqmserver",
"historelay",
"interval");
66 if (strcmp(relayhost,
"none") != 0) {
67 printf(
"DqmServer : command = %s %s %s %s %s\n",
68 hrelay, mapfile, relayhost, relayport, interval);
69 m_pid_relay = m_proc->Execute(hrelay, mapfile, relayhost, relayport,
81 printf(
"DqmServer : waiting 10 sec. for basf2 completion\n");
86 char* merger = m_conf->getconf(
"dqmserver",
"merger");
87 char* topdir = m_conf->getconf(
"system",
"execdir_base");
88 char* nodebase = m_conf->getconf(
"processor",
"nodebase");
89 char* nnodes = m_conf->getconf(
"processor",
"nnodes");
90 char* startnode = m_conf->getconf(
"processor",
"idbase");
91 char* badlist = m_conf->getconf(
"processor",
"badlist");
106 if (m_pid_dqm != 0) {
108 kill(m_pid_dqm, SIGINT);
109 waitpid(m_pid_dqm, &status, 0);
111 if (m_pid_relay != 0) {
113 kill(m_pid_relay, SIGINT);
114 waitpid(m_pid_relay, &status, 0);
117 printf(
"DqmServer : Unconfigure done\n");
123 m_expno = msgm->pars[0];
124 m_runno = msgm->pars[1];
125 printf(
"DqmServer : Started. Exp = %d, Run = %d\n", m_expno, m_runno);
132 printf(
"DqmServer : waiting 10 sec. for basf2 completion\n");
137 char* merger = m_conf->getconf(
"dqmserver",
"merger");
138 char* topdir = m_conf->getconf(
"system",
"execdir_base");
139 char* nodebase = m_conf->getconf(
"processor",
"nodebase");
140 char* nnodes = m_conf->getconf(
"processor",
"nnodes");
141 char* startnode = m_conf->getconf(
"processor",
"idbase");
142 char* badlist = m_conf->getconf(
"processor",
"badlist");
150 sprintf(outfile,
"dqm_e%4.4dr%6.6d.root", m_expno, m_runno);
154 int pid_dqmmerge = m_proc->Execute(merger, outfile, nodebase, topdir, nnodes, startnode, badlist);
161 pid_t done = waitpid(colpid, &status, 0);
163 printf(
"DqmServer : Stopped.\n");
171 printf(
"RFDqmServer : Restarted!!!!!\n");
182 RFDqmServer::UnConfigure(nsmmsg, nsmcontext);
184 RFDqmServer::Configure(nsmmsg, nsmcontext);
190 void RFDqmServer::server()
193 pid_t pid = m_proc->CheckProcess();
195 printf(
"RFDqmServer : process dead. pid=%d\n", pid);
196 if (pid == m_pid_dqm)
197 m_log->Error(
"RFDqmServer : Hserver process dead. pid=%d\n", pid);
198 else if (pid == m_pid_relay)
199 m_log->Error(
"RFDqmServer : Hrelay process dead. pid=%d\n", pid);
201 int st = m_proc->CheckOutput();
203 perror(
"RFDqmServer::server");
206 m_log->ProcessLog(m_proc->GetFd());
211 void RFDqmServer::cleanup()
213 printf(
"RFDqmServer : cleaning up\n");
214 UnConfigure(NULL, NULL);
215 printf(
"RFDqmServer: Done. Exitting\n");
Abstract base class for different kinds of events.