1 #include "daq/expreco/EventServerCallback.h"
16 void* RunEventServerLogger(
void*)
18 s_eventserver->EventServerLogger();
25 EventServerCallback::EventServerCallback()
30 m_conf =
new RFConf(getenv(
"ERECO_CONFFILE"));
35 EventServerCallback::~EventServerCallback() noexcept
40 void EventServerCallback::load(
const DBObject&)
44 char* nodename = m_conf->getconf(
"eventsampler",
"server",
"nodename");
45 string execdir = string(m_conf->getconf(
"system",
"execdir_base")) +
"/eventserver";
46 printf(
"execdir = %s\n", execdir.c_str());
48 mkdir(execdir.c_str(), 0755);
49 chdir(execdir.c_str());
59 char* server = m_conf->getconf(
"eventsampler",
"server",
"script");
60 char* rbuf = m_conf->getconf(
"eventsampler",
"ringbufout");
61 char* port = m_conf->getconf(
"eventsampler",
"server",
"port");
62 m_pid_server = m_proc->Execute(server, rbuf, port);
67 pthread_attr_t thread_attr;
68 pthread_attr_init(&thread_attr);
72 pthread_create(&m_logthread, NULL, RunEventServerLogger, NULL);
76 void EventServerCallback::start()
80 void EventServerCallback::stop()
84 void EventServerCallback::abort()
88 if (m_pid_server != 0) {
89 kill(m_pid_server, SIGINT);
90 waitpid(m_pid_server, &status, 0);
91 LogFile::info(
"killed event server (pid=%d)", m_pid_server);
94 pthread_cancel(m_logthread);
98 void EventServerCallback::recover(
const DBObject&)
103 void EventServerCallback::EventServerLogger()
106 int st = m_proc->CheckOutput();
108 perror(
"EventServerLogger::server");
111 m_log->ProcessLog(m_proc->GetFd());