10 #include "daq/rfarm/manager/RFDqmServer.h"
13 #include <sys/types.h>
22 RFDqmServer::RFDqmServer(
string conffile)
25 m_conf =
new RFConf(conffile.c_str());
26 char* nodename = m_conf->getconf(
"dqmserver",
"nodename");
31 string execdir = string(m_conf->getconf(
"system",
"execdir_base")) +
"/dqmserver";
33 mkdir(execdir.c_str(), 0755);
34 chdir(execdir.c_str());
40 m_log =
new RFLogManager(nodename, m_conf->getconf(
"system",
"lognode"));
43 RFDqmServer::~RFDqmServer()
55 char* dqmserver = m_conf->getconf(
"dqmserver",
"script");
56 char* port = m_conf->getconf(
"dqmserver",
"port");
57 char* mapfile = m_conf->getconf(
"dqmserver",
"mapfile");
59 m_pid_dqm = m_proc->Execute(dqmserver, port, mapfile);
62 char* relayhost = m_conf->getconf(
"dqmserver",
"historelay",
"host");
63 char* relayport = m_conf->getconf(
"dqmserver",
"historelay",
"port");
64 char* hrelay = m_conf->getconf(
"dqmserver",
"historelay",
"script");
65 char* interval = m_conf->getconf(
"dqmserver",
"historelay",
"interval");
67 if (strcmp(relayhost,
"none") != 0) {
68 printf(
"DqmServer : command = %s %s %s %s %s\n",
69 hrelay, mapfile, relayhost, relayport, interval);
70 m_pid_relay = m_proc->Execute(hrelay, mapfile, relayhost, relayport,
82 printf(
"DqmServer : waiting 10 sec. for basf2 completion\n");
87 char* merger = m_conf->getconf(
"dqmserver",
"merger");
88 char* topdir = m_conf->getconf(
"system",
"execdir_base");
89 char* nodebase = m_conf->getconf(
"processor",
"nodebase");
90 char* nnodes = m_conf->getconf(
"processor",
"nnodes");
91 char* startnode = m_conf->getconf(
"processor",
"idbase");
92 char* badlist = m_conf->getconf(
"processor",
"badlist");
107 if (m_pid_dqm != 0) {
109 kill(m_pid_dqm, SIGINT);
110 waitpid(m_pid_dqm, &status, 0);
112 if (m_pid_relay != 0) {
114 kill(m_pid_relay, SIGINT);
115 waitpid(m_pid_relay, &status, 0);
118 printf(
"DqmServer : Unconfigure done\n");
124 m_expno = msgm->pars[0];
125 m_runno = msgm->pars[1];
126 printf(
"DqmServer : Started. Exp = %d, Run = %d\n", m_expno, m_runno);
133 printf(
"DqmServer : waiting 10 sec. for basf2 completion\n");
138 char* merger = m_conf->getconf(
"dqmserver",
"merger");
139 char* topdir = m_conf->getconf(
"system",
"execdir_base");
140 char* nodebase = m_conf->getconf(
"processor",
"nodebase");
141 char* nnodes = m_conf->getconf(
"processor",
"nnodes");
142 char* startnode = m_conf->getconf(
"processor",
"idbase");
143 char* badlist = m_conf->getconf(
"processor",
"badlist");
151 sprintf(outfile,
"dqm_e%4.4dr%6.6d.root", m_expno, m_runno);
155 int pid_dqmmerge = m_proc->Execute(merger, outfile, nodebase, topdir, nnodes, startnode, badlist);
162 pid_t done = waitpid(colpid, &status, 0);
164 printf(
"DqmServer : Stopped.\n");
172 printf(
"RFDqmServer : Restarted!!!!!\n");
183 RFDqmServer::UnConfigure(nsmmsg, nsmcontext);
185 RFDqmServer::Configure(nsmmsg, nsmcontext);
191 void RFDqmServer::server()
194 pid_t pid = m_proc->CheckProcess();
196 printf(
"RFDqmServer : process dead. pid=%d\n", pid);
197 if (pid == m_pid_dqm)
198 m_log->Error(
"RFDqmServer : Hserver process dead. pid=%d\n", pid);
199 else if (pid == m_pid_relay)
200 m_log->Error(
"RFDqmServer : Hrelay process dead. pid=%d\n", pid);
202 int st = m_proc->CheckOutput();
204 perror(
"RFDqmServer::server");
207 m_log->ProcessLog(m_proc->GetFd());
212 void RFDqmServer::cleanup()
214 printf(
"RFDqmServer : cleaning up\n");
215 UnConfigure(NULL, NULL);
216 printf(
"RFDqmServer: Done. Exitting\n");