9#include "daq/rfarm/manager/RFDqmServer.h"
21RFDqmServer::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"));
42RFDqmServer::~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");
85 m_conf->getconf(
"dqmserver",
"merger");
86 m_conf->getconf(
"system",
"execdir_base");
87 m_conf->getconf(
"processor",
"nodebase");
88 m_conf->getconf(
"processor",
"nnodes");
89 m_conf->getconf(
"processor",
"idbase");
90 m_conf->getconf(
"processor",
"badlist");
104 if (m_pid_dqm != 0) {
106 kill(m_pid_dqm, SIGINT);
107 waitpid(m_pid_dqm, &status, 0);
109 if (m_pid_relay != 0) {
111 kill(m_pid_relay, SIGINT);
112 waitpid(m_pid_relay, &status, 0);
115 printf(
"DqmServer : Unconfigure done\n");
121 m_expno = msgm->pars[0];
122 m_runno = msgm->pars[1];
123 printf(
"DqmServer : Started. Exp = %d, Run = %d\n", m_expno, m_runno);
130 printf(
"DqmServer : waiting 10 sec. for basf2 completion\n");
135 char* merger = m_conf->getconf(
"dqmserver",
"merger");
136 char* topdir = m_conf->getconf(
"system",
"execdir_base");
137 char* nodebase = m_conf->getconf(
"processor",
"nodebase");
138 char* nnodes = m_conf->getconf(
"processor",
"nnodes");
139 char* startnode = m_conf->getconf(
"processor",
"idbase");
140 char* badlist = m_conf->getconf(
"processor",
"badlist");
148 sprintf(outfile,
"dqm_e%4.4dr%6.6d.root", m_expno, m_runno);
152 m_proc->
Execute(merger, outfile, nodebase, topdir, nnodes, startnode, badlist);
159 waitpid(colpid, &status, 0);
161 printf(
"DqmServer : Stopped.\n");
169 printf(
"RFDqmServer : Restarted!!!!!\n");
180 RFDqmServer::UnConfigure(nsmmsg, nsmcontext);
182 RFDqmServer::Configure(nsmmsg, nsmcontext);
188void RFDqmServer::server()
191 pid_t pid = m_proc->CheckProcess();
193 printf(
"RFDqmServer : process dead. pid=%d\n", pid);
194 if (pid == m_pid_dqm)
195 m_log->Error(
"RFDqmServer : Hserver process dead. pid=%d\n", pid);
196 else if (pid == m_pid_relay)
197 m_log->Error(
"RFDqmServer : Hrelay process dead. pid=%d\n", pid);
199 int st = m_proc->CheckOutput();
201 perror(
"RFDqmServer::server");
204 m_log->ProcessLog(m_proc->GetFd());
209void RFDqmServer::cleanup()
211 printf(
"RFDqmServer : cleaning up\n");
212 UnConfigure(NULL, NULL);
213 printf(
"RFDqmServer: Done. Exitting\n");
int Execute(char *script, int nargs, char **args)
Abstract base class for different kinds of events.