mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 15:05:11 +00:00
[MOD/WIP] Allow flat-file support, manpage updates
This commit is contained in:
parent
de8fd53a6f
commit
6c32868ca0
6 changed files with 30 additions and 9 deletions
2
Makefile
2
Makefile
|
|
@ -61,7 +61,7 @@ $(AYAS)/%.html: $(INCLUDES)/%.h
|
||||||
|
|
||||||
# Installs everything.
|
# Installs everything.
|
||||||
install: binary utils ayadoc install_setup install_parsee install_tools install_aya install_man
|
install: binary utils ayadoc install_setup install_parsee install_tools install_aya install_man
|
||||||
@echo Installing $(NAME) to $(PREFIX)
|
@echo Installed $(NAME) to $(PREFIX)!
|
||||||
|
|
||||||
install_setup:
|
install_setup:
|
||||||
install -dm755 "$(PREFIX)/bin"
|
install -dm755 "$(PREFIX)/bin"
|
||||||
|
|
|
||||||
14
src/Main.c
14
src/Main.c
|
|
@ -40,7 +40,6 @@ Main(Array *args, HashMap *env)
|
||||||
Cron *cron = NULL;
|
Cron *cron = NULL;
|
||||||
|
|
||||||
start = UtilTsMillis();
|
start = UtilTsMillis();
|
||||||
/* TODO: Read args(config file, HTTP/XMPP threads, ...) */
|
|
||||||
|
|
||||||
memset(&conf, 0, sizeof(conf));
|
memset(&conf, 0, sizeof(conf));
|
||||||
Log(LOG_INFO,
|
Log(LOG_INFO,
|
||||||
|
|
@ -61,7 +60,7 @@ Main(Array *args, HashMap *env)
|
||||||
int http = 8;
|
int http = 8;
|
||||||
|
|
||||||
ArgParseStateInit(&state);
|
ArgParseStateInit(&state);
|
||||||
while ((flag = ArgParse(&state, args, "H:J:")) != -1)
|
while ((flag = ArgParse(&state, args, "gH:J:")) != -1)
|
||||||
{
|
{
|
||||||
switch (flag)
|
switch (flag)
|
||||||
{
|
{
|
||||||
|
|
@ -71,14 +70,17 @@ Main(Array *args, HashMap *env)
|
||||||
case 'J':
|
case 'J':
|
||||||
xmpp = strtol(state.optArg, NULL, 10);
|
xmpp = strtol(state.optArg, NULL, 10);
|
||||||
break;
|
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);
|
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...");
|
Log(LOG_NOTICE, "Connecting to XMPP...");
|
||||||
jabber = XMPPInitialiseCompStream(
|
jabber = XMPPInitialiseCompStream(
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,7 @@ ParseeConfigInit(void)
|
||||||
config->hs_token = StrRandom(32);
|
config->hs_token = StrRandom(32);
|
||||||
config->http_threads = 8;
|
config->http_threads = 8;
|
||||||
config->xmpp_threads = 8;
|
config->xmpp_threads = 8;
|
||||||
|
config->db_size = 64 MB;
|
||||||
|
|
||||||
/* TODO: This is NOT user friendly, and I know it! */
|
/* TODO: This is NOT user friendly, and I know it! */
|
||||||
config->sender_localpart = PromptString(
|
config->sender_localpart = PromptString(
|
||||||
|
|
@ -260,6 +261,7 @@ ParseeConfigLoad(char *conf)
|
||||||
CopyToStr(media_base, "media_base");
|
CopyToStr(media_base, "media_base");
|
||||||
|
|
||||||
CopyToStr(db_path, "db");
|
CopyToStr(db_path, "db");
|
||||||
|
CopyToInt(db_size, "db_size");
|
||||||
|
|
||||||
JsonFree(json);
|
JsonFree(json);
|
||||||
StreamClose(stream);
|
StreamClose(stream);
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,17 @@ ParseeInitData(XMPPComponent *comp)
|
||||||
data->router = HttpRouterCreate();
|
data->router = HttpRouterCreate();
|
||||||
data->jabber = comp;
|
data->jabber = comp;
|
||||||
data->handler = CommandCreateRouter();
|
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 {\
|
#define X_ROUTE(path, func) do {\
|
||||||
if (!HttpRouterAdd(data->router, path, func))\
|
if (!HttpRouterAdd(data->router, path, func))\
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ typedef struct ParseeConfig {
|
||||||
|
|
||||||
/* ------- DB -------- */
|
/* ------- DB -------- */
|
||||||
char *db_path;
|
char *db_path;
|
||||||
|
size_t db_size;
|
||||||
|
|
||||||
/* - COMMAND-LINE FLAGS - */
|
/* - COMMAND-LINE FLAGS - */
|
||||||
int xmpp_threads, http_threads;
|
int xmpp_threads, http_threads;
|
||||||
|
|
|
||||||
|
|
@ -88,11 +88,12 @@ Main(Array *args, HashMap *env)
|
||||||
char *data = NULL, *media = NULL, *listen = NULL;
|
char *data = NULL, *media = NULL, *listen = NULL;
|
||||||
int flag, code = EXIT_FAILURE;
|
int flag, code = EXIT_FAILURE;
|
||||||
int port = 5347;
|
int port = 5347;
|
||||||
|
size_t lmdb_size = 0;
|
||||||
|
|
||||||
listen = "localhost";
|
listen = "localhost";
|
||||||
|
|
||||||
ArgParseStateInit(&state);
|
ArgParseStateInit(&state);
|
||||||
while ((flag = ArgParse(&state, args, "H:J:s:d:p:m:l:")) != -1)
|
while ((flag = ArgParse(&state, args, "H:J:s:d:p:m:l:S:")) != -1)
|
||||||
{
|
{
|
||||||
switch (flag)
|
switch (flag)
|
||||||
{
|
{
|
||||||
|
|
@ -118,6 +119,9 @@ Main(Array *args, HashMap *env)
|
||||||
case 'p':
|
case 'p':
|
||||||
port = strtol(state.optArg, NULL, 10);
|
port = strtol(state.optArg, NULL, 10);
|
||||||
break;
|
break;
|
||||||
|
case 'S':
|
||||||
|
lmdb_size = strtol(state.optArg, NULL, 10) * 1024 * 1024;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,6 +137,7 @@ Main(Array *args, HashMap *env)
|
||||||
"-l [Host/IP to listen as] "
|
"-l [Host/IP to listen as] "
|
||||||
"-p [XMPP component port=5347] "
|
"-p [XMPP component port=5347] "
|
||||||
"-J [parsee.xmppserver.ex]",
|
"-J [parsee.xmppserver.ex]",
|
||||||
|
"-S [LMDB size]",
|
||||||
ArrayGet(args, 0)
|
ArrayGet(args, 0)
|
||||||
);
|
);
|
||||||
goto end;
|
goto end;
|
||||||
|
|
@ -155,6 +160,7 @@ Main(Array *args, HashMap *env)
|
||||||
UtilMkdir(data, 0755);
|
UtilMkdir(data, 0755);
|
||||||
|
|
||||||
JsonSet(json, JsonValueString(data), 1, "db");
|
JsonSet(json, JsonValueString(data), 1, "db");
|
||||||
|
JsonSet(json, JsonValueInteger(lmdb_size), 1, "db_size");
|
||||||
|
|
||||||
JsonSet(json, JsonValueString(homeserver), 1, "hs_base");
|
JsonSet(json, JsonValueString(homeserver), 1, "hs_base");
|
||||||
JsonSet(json, JsonValueString(api_base->host), 1, "hs_host");
|
JsonSet(json, JsonValueString(api_base->host), 1, "hs_host");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue