[MOD/WIP] Allow flat-file support, manpage updates

This commit is contained in:
LDA 2024-08-12 18:54:35 +02:00
commit 6c32868ca0
6 changed files with 30 additions and 9 deletions

View file

@ -40,7 +40,6 @@ Main(Array *args, HashMap *env)
Cron *cron = NULL;
start = UtilTsMillis();
/* TODO: Read args(config file, HTTP/XMPP threads, ...) */
memset(&conf, 0, sizeof(conf));
Log(LOG_INFO,
@ -61,7 +60,7 @@ Main(Array *args, HashMap *env)
int http = 8;
ArgParseStateInit(&state);
while ((flag = ArgParse(&state, args, "H:J:")) != -1)
while ((flag = ArgParse(&state, args, "gH:J:")) != -1)
{
switch (flag)
{
@ -71,14 +70,17 @@ Main(Array *args, HashMap *env)
case 'J':
xmpp = strtol(state.optArg, NULL, 10);
break;
case 'g':
/* Write out the config file to a YAML document */
Log(LOG_INFO, "Generating YAML...");
yaml = StreamOpen("parsee.yaml", "w");
ParseeExportConfigYAML(yaml);
StreamClose(yaml);
goto end;
}
}
ParseeSetThreads(xmpp, http);
}
/* Write out the config file to a YAML document */
yaml = StreamOpen("parsee.yaml", "w");
ParseeExportConfigYAML(yaml);
StreamClose(yaml);
Log(LOG_NOTICE, "Connecting to XMPP...");
jabber = XMPPInitialiseCompStream(

View file

@ -135,6 +135,7 @@ ParseeConfigInit(void)
config->hs_token = StrRandom(32);
config->http_threads = 8;
config->xmpp_threads = 8;
config->db_size = 64 MB;
/* TODO: This is NOT user friendly, and I know it! */
config->sender_localpart = PromptString(
@ -260,6 +261,7 @@ ParseeConfigLoad(char *conf)
CopyToStr(media_base, "media_base");
CopyToStr(db_path, "db");
CopyToInt(db_size, "db_size");
JsonFree(json);
StreamClose(stream);

View file

@ -27,7 +27,17 @@ ParseeInitData(XMPPComponent *comp)
data->router = HttpRouterCreate();
data->jabber = comp;
data->handler = CommandCreateRouter();
data->db = DbOpenLMDB(data->config->db_path, 64 MB);
if (data->config->db_size)
{
data->db = DbOpenLMDB(data->config->db_path, data->config->db_size);
}
if (!data->db)
{
Log(LOG_WARNING, "LMDB doesn't seem to be setup.");
Log(LOG_WARNING, "Falling back to flat-file.");
data->db = DbOpen(data->config->db_path, 0);
}
#define X_ROUTE(path, func) do {\
if (!HttpRouterAdd(data->router, path, func))\

View file

@ -41,6 +41,7 @@ typedef struct ParseeConfig {
/* ------- DB -------- */
char *db_path;
size_t db_size;
/* - COMMAND-LINE FLAGS - */
int xmpp_threads, http_threads;