8#include "daq/expreco/EventServerCallback.h"
23void* RunEventServerLogger(
void*)
25 s_eventserver->EventServerLogger();
32EventServerCallback::EventServerCallback()
37 m_conf =
new RFConf(getenv(
"ERECO_CONFFILE"));
42EventServerCallback::~EventServerCallback() noexcept
47void EventServerCallback::load(
const DBObject&,
const std::string&)
51 char* nodename = m_conf->getconf(
"eventsampler",
"server",
"nodename");
52 string execdir = string(m_conf->getconf(
"system",
"execdir_base")) +
"/eventserver";
53 printf(
"execdir = %s\n", execdir.c_str());
55 mkdir(execdir.c_str(), 0755);
56 chdir(execdir.c_str());
66 char* server = m_conf->getconf(
"eventsampler",
"server",
"script");
67 char* rbuf = m_conf->getconf(
"eventsampler",
"ringbufout");
68 char* port = m_conf->getconf(
"eventsampler",
"server",
"port");
69 m_pid_server = m_proc->
Execute(server, rbuf, port);
74 pthread_attr_t thread_attr;
75 pthread_attr_init(&thread_attr);
79 pthread_create(&m_logthread, NULL, RunEventServerLogger, NULL);
83void EventServerCallback::abort()
87 if (m_pid_server != 0) {
88 kill(m_pid_server, SIGINT);
89 waitpid(m_pid_server, &status, 0);
90 LogFile::info(
"killed event server (pid=%d)", m_pid_server);
93 pthread_cancel(m_logthread);
97void EventServerCallback::EventServerLogger()
100 int st = m_proc->CheckOutput();
102 perror(
"EventServerLogger::server");
105 m_log->ProcessLog(m_proc->GetFd());
int Execute(char *script, int nargs, char **args)
Abstract base class for different kinds of events.