initial commit

This commit is contained in:
Doug Hoyte
2022-12-19 14:42:40 -05:00
commit c47d07e985
42 changed files with 4652 additions and 0 deletions

56
src/cmd_relay.cpp Normal file
View File

@ -0,0 +1,56 @@
#include "RelayServer.h"
void cmd_relay(const std::vector<std::string> &subArgs) {
RelayServer s;
s.run();
}
void RelayServer::run() {
tpWebsocket.init("Websocket", 1, [this](auto &thr){
runWebsocket(thr);
});
tpIngester.init("Ingester", cfg().relay__numThreads__ingester, [this](auto &thr){
runIngester(thr);
});
tpWriter.init("Writer", 1, [this](auto &thr){
runWriter(thr);
});
tpReqWorker.init("ReqWorker", cfg().relay__numThreads__reqWorker, [this](auto &thr){
runReqWorker(thr);
});
tpReqMonitor.init("ReqMonitor", cfg().relay__numThreads__reqMonitor, [this](auto &thr){
runReqMonitor(thr);
});
tpYesstr.init("Yesstr", cfg().relay__numThreads__yesstr, [this](auto &thr){
runYesstr(thr);
});
// Monitor for config file reloads
auto configFileChangeWatcher = hoytech::file_change_monitor(configFile);
configFileChangeWatcher.setDebounce(100);
configFileChangeWatcher.run([&](){
loadConfig(configFile);
});
// Cron
cron.repeat(10 * 1'000'000UL, [&]{
cleanupOldEvents();
});
cron.setupCb = []{ setThreadName("cron"); };
cron.run();
tpWebsocket.join();
}