You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-08 14:22:09 +03:00
MCOL-4170 Refactor services/systemd units to finish their bootstrap ...
This commit is contained in:
@@ -35,9 +35,48 @@ using namespace std;
|
||||
#include "Synchronizer.h"
|
||||
#include "Replicator.h"
|
||||
#include "crashtrace.h"
|
||||
#include "service.h"
|
||||
|
||||
using namespace storagemanager;
|
||||
|
||||
|
||||
class Opt
|
||||
{
|
||||
public:
|
||||
const char *m_progname;
|
||||
bool m_fg;
|
||||
Opt(int argc, char **argv)
|
||||
:m_progname(argv[0]),
|
||||
m_fg(argc >= 2 && string(argv[1]) == "fg")
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
class ServiceStorageManager: public Service, public Opt
|
||||
{
|
||||
protected:
|
||||
void setupChildSignalHandlers();
|
||||
|
||||
public:
|
||||
ServiceStorageManager(const Opt &opt)
|
||||
:Service("StorageManager"), Opt(opt)
|
||||
{ }
|
||||
void LogErrno() override
|
||||
{
|
||||
SMLogging::get()->log(LOG_ERR, "%s", strerror(errno));
|
||||
}
|
||||
void ParentLogChildMessage(const std::string &str) override
|
||||
{
|
||||
SMLogging::get()->log(LOG_INFO, "%.*s", (int) str.length(), str.data());
|
||||
}
|
||||
int Child() override;
|
||||
int Run()
|
||||
{
|
||||
return m_fg ? Child() : RunForking();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
bool signalCaught = false;
|
||||
|
||||
void printCacheUsage(int sig)
|
||||
@@ -75,7 +114,7 @@ void coreSM(int sig)
|
||||
}
|
||||
|
||||
|
||||
static void setupSignalHandlers()
|
||||
void ServiceStorageManager::setupChildSignalHandlers()
|
||||
{
|
||||
struct sigaction sa;
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
@@ -106,7 +145,7 @@ static void setupSignalHandlers()
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int ServiceStorageManager::Child()
|
||||
{
|
||||
|
||||
SMLogging* logger = SMLogging::get();
|
||||
@@ -129,14 +168,16 @@ int main(int argc, char** argv)
|
||||
return -1;
|
||||
}
|
||||
|
||||
setupSignalHandlers();
|
||||
|
||||
setupChildSignalHandlers();
|
||||
|
||||
int ret = 0;
|
||||
|
||||
logger->log(LOG_NOTICE,"StorageManager started.");
|
||||
|
||||
SessionManager* sm = SessionManager::get();
|
||||
|
||||
NotifyServiceStarted();
|
||||
|
||||
ret = sm->start();
|
||||
|
||||
cache->shutdown();
|
||||
@@ -150,3 +191,8 @@ int main(int argc, char** argv)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
return ServiceStorageManager(Opt(argc, argv)).Run();
|
||||
}
|
||||
|
Reference in New Issue
Block a user