- rest_server is now a complete binary, just needs more config options boilerplate.

This commit is contained in:
Ian Roddis
2021-08-20 11:18:26 -03:00
parent 1f2712b090
commit 0f1f00362c

View File

@@ -13,16 +13,17 @@
#include <daggy/loggers/dag_run/FileSystemLogger.hpp>
struct Options {
Pistache::IP listenAddress = Pistache::Ipv4::any();
std::string listenIP = "localhost";
fs::path logFile = "daggy.log";
uint16_t listenPort = 2503;
size_t webThreads = 50;
size_t dagThreads = 20;
std::unique_ptr<daggy::executors::task::TaskExecutor> executor;
std::unique_ptr<daggy::loggers::dag_run::DAGRunLogger> logger;
size_t taskThreads = 20;
};
int main(int argc, char **argv) {
Options options;
argparse::ArgumentParser args("Daggy");
args.add_argument("-v", "--verbose");
@@ -34,7 +35,12 @@ int main(int argc, char **argv) {
.help("Port to listen to")
.action([](const std::string &value) { return std::stoi(value); });
// Set some defaults
std::ofstream logFile(options.logFile, std::ios::app);
daggy::loggers::dag_run::OStreamLogger logger(logFile);
daggy::executors::task::ForkingTaskExecutor executor(options.taskThreads);
Pistache::Address listenSpec(options.listenIP, options.listenPort);
// daggy::Server endpoint(10);
daggy::Server server(listenSpec, logger, executor, options.dagThreads);
server.init(options.webThreads);
server.start();
}