[MOD] -J and -H flags for the max XMPP/HTTP thread

This commit is contained in:
LDA 2024-08-10 14:10:09 +02:00
commit 4d6ba32e98
5 changed files with 58 additions and 10 deletions

View file

@ -3,12 +3,14 @@
#include <Cytoplasm/Memory.h>
#include <Cytoplasm/Util.h>
#include <Cytoplasm/Cron.h>
#include <Cytoplasm/Args.h>
#include <Cytoplasm/Log.h>
#include <Cytoplasm/Str.h>
#include <pthread.h>
#include <string.h>
#include <signal.h>
#include <stdlib.h>
#include <StringStream.h>
#include <Parsee.h>
@ -30,7 +32,7 @@ ParseeUptime(void)
}
int
Main(void)
Main(Array *args, HashMap *env)
{
HttpServerConfig conf;
const ParseeConfig *parsee_conf;
@ -50,13 +52,34 @@ Main(void)
ParseeConfigLoad("parsee.json");
ParseeConfigInit();
parsee_conf = ParseeConfigGet();
{
ArgParseState state;
int flag;
int xmpp = 8;
int http = 8;
ArgParseStateInit(&state);
while ((flag = ArgParse(&state, args, "H:J:")) != -1)
{
switch (flag)
{
case 'H':
http = strtol(state.optArg, NULL, 10);
break;
case 'J':
xmpp = strtol(state.optArg, NULL, 10);
break;
}
}
ParseeSetThreads(xmpp, http);
}
/* Write out the config file to a YAML document */
yaml = StreamOpen("parsee.yaml", "w");
ParseeExportConfigYAML(yaml);
StreamClose(yaml);
parsee_conf = ParseeConfigGet();
{
Log(LOG_NOTICE, "Connecting to XMPP...");
jabber = XMPPInitialiseCompStream(
@ -83,8 +106,8 @@ Main(void)
ASRegisterUser(parsee_conf, parsee_conf->sender_localpart);
conf.port = parsee_conf->port;
conf.threads = 4;
conf.maxConnections = 32;
conf.threads = parsee_conf->http_threads;
conf.maxConnections = 32; /* TODO */
conf.handlerArgs = ParseeInitData(jabber);
conf.handler = ParseeRequest;