1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

MCOL-4170 Refactor services/systemd units to finish their bootstrap ...

This commit is contained in:
Alexander Barkov
2020-10-07 12:38:09 +04:00
parent 2992ee3c31
commit ab44ef6ddb
21 changed files with 875 additions and 181 deletions

View File

@ -66,8 +66,76 @@ using namespace execplan;
#include "collation.h"
#include "service.h"
namespace
{
class Opt
{
public:
int m_debug;
bool m_fg;
Opt(int argc, char *argv[])
:m_debug(0),
m_fg(false)
{
int c;
while ((c = getopt(argc, argv, "df")) != EOF)
{
switch(c)
{
case 'd':
m_debug++; // TODO: not really used yes
break;
case 'f':
m_fg= true;
break;
case '?':
default:
break;
}
}
}
};
class ServiceDDLProc: public Service, public Opt
{
protected:
void setupChildSignalHandlers();
void log(logging::LOG_TYPE type, const std::string &str)
{
LoggingID logid(23, 0, 0);
Message::Args args;
Message message(8);
args.add(str);
message.format(args);
logging::Logger logger(logid.fSubsysID);
logger.logMessage(LOG_TYPE_CRITICAL, message, logid);
}
public:
ServiceDDLProc(const Opt &opt)
:Service("DDLProc"), Opt(opt)
{ }
void LogErrno() override
{
log(LOG_TYPE_CRITICAL, std::string(strerror(errno)));
}
void ParentLogChildMessage(const std::string &str) override
{
log(LOG_TYPE_INFO, str);
}
int Child() override;
int Run()
{
return m_fg ? Child() : RunForking();
}
};
DistributedEngineComm* Dec;
int8_t setupCwd()
@ -95,7 +163,7 @@ void added_a_pm(int)
}
static void setupSignalHandlers()
void ServiceDDLProc::setupChildSignalHandlers()
{
#ifndef _MSC_VER
/* set up some signal handlers */
@ -114,16 +182,8 @@ static void setupSignalHandlers()
}
int main(int argc, char* argv[])
int ServiceDDLProc::Child()
{
// Set locale language
setlocale(LC_ALL, "");
setlocale(LC_NUMERIC, "C");
// Initialize the charset library
my_init();
// This is unset due to the way we start it
program_invocation_short_name = const_cast<char*>("DDLProc");
if ( setupCwd() < 0 )
{
LoggingID logid(23, 0, 0);
@ -133,6 +193,7 @@ int main(int argc, char* argv[])
msg.format( args1 );
logging::Logger logger(logid.fSubsysID);
logger.logMessage(LOG_TYPE_CRITICAL, msg, logid);
NotifyServiceInitializationFailed();
return 1;
}
@ -147,10 +208,12 @@ int main(int argc, char* argv[])
ResourceManager* rm = ResourceManager::instance();
Dec = DistributedEngineComm::instance(rm);
setupSignalHandlers();
setupChildSignalHandlers();
ddlprocessor::DDLProcessor ddlprocessor(1, 20);
NotifyServiceStarted();
{
Oam oam;
@ -218,5 +281,20 @@ int main(int argc, char* argv[])
return 0;
}
int main(int argc, char** argv)
{
Opt opt(argc, argv);
// Set locale language
setlocale(LC_ALL, "");
setlocale(LC_NUMERIC, "C");
// This is unset due to the way we start it
program_invocation_short_name = const_cast<char*>("DDLProc");
// Initialize the charset library
my_init();
return ServiceDDLProc(opt).Run();
}
// vim:ts=4 sw=4: