Renaming rest_server to daggyd, and daggy to libdaggy
This commit is contained in:
@@ -1 +1 @@
|
||||
add_subdirectory(rest_server)
|
||||
add_subdirectory(daggyd)
|
||||
@@ -1,4 +1,4 @@
|
||||
project(rest_server)
|
||||
project(daggyd)
|
||||
file(GLOB SOURCES *.cpp)
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
target_link_libraries(${PROJECT_NAME} pistache stdc++fs rapidjson argparse daggy)
|
||||
target_link_libraries(${PROJECT_NAME} pistache stdc++fs rapidjson argparse libdaggy)
|
||||
66
utils/daggyd/daggyd.cpp
Normal file
66
utils/daggyd/daggyd.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <argparse.hpp>
|
||||
|
||||
#include <daggy/Server.hpp>
|
||||
|
||||
// Add executors here
|
||||
#include <daggy/executors/task/ForkingTaskExecutor.hpp>
|
||||
|
||||
// Add loggers here
|
||||
#include <daggy/loggers/dag_run/OStreamLogger.hpp>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
argparse::ArgumentParser args("Daggy");
|
||||
|
||||
args.add_argument("-v", "--verbose")
|
||||
.default_value(false)
|
||||
.implicit_value(true);
|
||||
args.add_argument("-d", "--daemon")
|
||||
.default_value(false)
|
||||
.implicit_value(true);
|
||||
args.add_argument("--ip")
|
||||
.help("IP address to listen to")
|
||||
.default_value("localhost");
|
||||
args.add_argument("--log-file")
|
||||
.help("File to log to.")
|
||||
.default_value("daggyd.log");
|
||||
args.add_argument("--port")
|
||||
.help("Port to listen to")
|
||||
.default_value(2503)
|
||||
.action([](const std::string &value) { return std::stoi(value); });
|
||||
args.add_argument("--dag-threads")
|
||||
.help("Number of DAGs to run concurrently")
|
||||
.default_value(10)
|
||||
.action([](const std::string &value) { return std::stoull(value); });
|
||||
args.add_argument("--web-threads")
|
||||
.help("Number of web requests to support concurrently")
|
||||
.default_value(30)
|
||||
.action([](const std::string &value) { return std::stoull(value); });
|
||||
args.add_argument("--executor-threads")
|
||||
.help("Number of tasks to run concurrently")
|
||||
.default_value(30)
|
||||
.action([](const std::string &value) { return std::stoull(value); });
|
||||
|
||||
try {
|
||||
args.parse_args(argc, argv);
|
||||
} catch (std::exception &e) {
|
||||
std::cout << "Error: " << e.what() << std::endl;
|
||||
std::cout << args;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
std::ofstream logFile(args.get<std::string>("--log-file"), std::ios::app);
|
||||
daggy::loggers::dag_run::OStreamLogger logger(logFile);
|
||||
daggy::executors::task::ForkingTaskExecutor executor(args.get<size_t>("--executor-threads"));
|
||||
Pistache::Address listenSpec(args.get<std::string>("--ip"), args.get<uint16_t>("--port"));
|
||||
|
||||
daggy::Server server(listenSpec, logger, executor, args.get<size_t>("--dag-threads"));
|
||||
server.init(args.get<size_t>("--web-threads"));
|
||||
server.start();
|
||||
std::cout << "Server running at http://localhost:2503, Ctrl-C to exit" << std::endl;
|
||||
while (true) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(30));
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <argparse.hpp>
|
||||
|
||||
#include <daggy/Server.hpp>
|
||||
|
||||
// Add executors here
|
||||
#include <daggy/executors/task/ForkingTaskExecutor.hpp>
|
||||
|
||||
// Add loggers here
|
||||
#include <daggy/loggers/dag_run/OStreamLogger.hpp>
|
||||
|
||||
struct Options {
|
||||
std::string listenIP = "localhost";
|
||||
fs::path logFile = "daggy.log";
|
||||
uint16_t listenPort = 2503;
|
||||
size_t webThreads = 50;
|
||||
size_t dagThreads = 20;
|
||||
size_t taskThreads = 20;
|
||||
};
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
/*
|
||||
Options options;
|
||||
|
||||
argparse::ArgumentParser args("Daggy");
|
||||
|
||||
args.add_argument("-v", "--verbose");
|
||||
args.add_argument("-c", "--config")
|
||||
.help("Config file");
|
||||
args.add_argument("--ip")
|
||||
.help("IP address to listen to");
|
||||
args.add_argument("--port")
|
||||
.help("Port to listen to")
|
||||
.action([](const std::string &value) { return std::stoi(value); });
|
||||
*/
|
||||
|
||||
std::ofstream logFile("daggy.log", std::ios::app);
|
||||
daggy::loggers::dag_run::OStreamLogger logger(logFile);
|
||||
daggy::executors::task::ForkingTaskExecutor executor(32);
|
||||
Pistache::Address listenSpec("localhost", 2503);
|
||||
|
||||
daggy::Server server(listenSpec, logger, executor, 25);
|
||||
server.init(25);
|
||||
server.start();
|
||||
std::cout << "Server running at http://localhost:2503, Ctrl-C to exit" << std::endl;
|
||||
while (true) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(30));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user