[META] Actually start licensing

If anyone finds this to be bad, please let me know so that I can fix
that out.
This commit is contained in:
LDA 2024-06-23 01:22:10 +02:00
commit 4de7227ee7
7 changed files with 896 additions and 50 deletions

View file

@ -18,34 +18,6 @@ static HttpServer *server = NULL;
static pthread_t xmpp_thr;
static XMPPComponent *jabber = NULL;
static void
SignalHandler(int signal)
{
size_t i;
XMLElement *message, *body, *data;
char *from;
switch (signal)
{
case SIGPIPE:
return;
case SIGUSR1:
/* TODO: Soft-restart everything */
return;
case SIGTERM:
case SIGINT:
if (!server)
{
return;
}
/* Create a loopback stanza, forcing the thread to die */
Log(LOG_INFO, "Killing thread...");
XMPPKillThread(jabber, "killer");
pthread_join(xmpp_thr, NULL);
HttpServerStop(server);
break;
}
}
int
Main(void)
@ -54,7 +26,6 @@ Main(void)
ParseeData *data = NULL;
const ParseeConfig *parsee_conf;
Stream *yaml;
struct sigaction sigAction;
Log(LOG_INFO,
"%s - v%s (Cytoplasm %s)",
@ -111,29 +82,13 @@ Main(void)
ParseeSendPresence(conf.handlerArgs);
LogConfigUnindent(LogConfigGlobal());
sigAction.sa_handler = SignalHandler;
sigfillset(&sigAction.sa_mask);
sigAction.sa_flags = SA_RESTART;
server = HttpServerCreate(&conf);
/* TODO: I stole that from Telodendria. Sorry, Jordan! */
#define SIGACTION(sig, act, oact) \
if (sigaction(sig, act, oact) < 0) \
{ \
Log(LOG_ERR, "Unable to install signal handler: %s", #sig); \
goto end; \
} \
else \
{ \
Log(LOG_DEBUG, "Installed signal handler: %s", #sig); \
if (!ParseeInitialiseSignals(server, xmpp_thr, jabber))
{
goto end;
}
SIGACTION(SIGINT, &sigAction, NULL);
SIGACTION(SIGTERM, &sigAction, NULL);
SIGACTION(SIGPIPE, &sigAction, NULL);
SIGACTION(SIGUSR1, &sigAction, NULL); /* Make USR1 do a softrestart */
#undef SIGACTION
server = HttpServerCreate(&conf);
HttpServerStart(server);
LogConfigUnindent(LogConfigGlobal());
Log(LOG_INFO, "=======================");