1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +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

@ -86,10 +86,90 @@ using namespace joblist;
#include "collation.h"
#include "service.h"
threadpool::ThreadPool DMLServer::fDmlPackagepool(10, 0);
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 ServiceDMLProc: public Service, public Opt
{
protected:
int Parent() override
{
/*
Need to shutdown TheadPool,
otherwise it would get stuck when trying to join fPruneThread.
*/
joblist::JobStep::jobstepThreadPool.stop();
return Service::Parent();
}
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);
}
void setupChildSignalHandlers();
public:
ServiceDMLProc(const Opt &opt)
:Service("DMLProc"), 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;
void added_a_pm(int)
@ -510,7 +590,7 @@ int8_t setupCwd()
} // Namewspace
static void setupSignalHandlers()
void ServiceDMLProc::setupChildSignalHandlers()
{
#ifndef _MSC_VER
/* set up some signal handlers */
@ -530,18 +610,10 @@ static void setupSignalHandlers()
}
int main(int argc, char* argv[])
int ServiceDMLProc::Child()
{
BRM::DBRM dbrm;
Oam oam;
// 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*>("DMLProc");
Config* cf = Config::makeConfig();
@ -554,6 +626,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;
}
@ -581,6 +654,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;
}
catch (...)
@ -593,6 +667,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;
}
@ -623,6 +698,7 @@ int main(int argc, char* argv[])
ml.logCriticalMessage( message );
cerr << "DMLProc failed to start due to : " << e.what() << endl;
NotifyServiceInitializationFailed();
return 1;
}
@ -664,6 +740,9 @@ int main(int argc, char* argv[])
}
DMLServer dmlserver(serverThreads, serverQueueSize, &dbrm);
NotifyServiceStarted();
ResourceManager* rm = ResourceManager::instance();
// jobstepThreadPool is used by other processes. We can't call
@ -715,11 +794,28 @@ int main(int argc, char* argv[])
Dec = DistributedEngineComm::instance(rm);
setupSignalHandlers();
setupChildSignalHandlers();
dmlserver.start();
return 1;
}
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*>("DMLProc");
// Initialize the charset library
my_init();
return ServiceDMLProc(opt).Run();
}
// vim:ts=4 sw=4: