Db
This commit is contained in:
37
src/main.cpp
37
src/main.cpp
@@ -1,14 +1,35 @@
|
||||
#include "server.hpp"
|
||||
#include "config.hpp"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
namespace simple_object_storage {
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
std::filesystem::path config_path = std::filesystem::path(std::getenv("HOME")) / ".config/dropshell_template_registry/config.json";
|
||||
std::filesystem::path config_path = std::filesystem::path(std::getenv("HOME")) / ".config/simple_object_storage/config.json";
|
||||
std::filesystem::create_directories(config_path.parent_path());
|
||||
|
||||
dropshell::ServerConfig config;
|
||||
if (!dropshell::load_config(config_path, config)) {
|
||||
ServerConfig config;
|
||||
if (!simple_object_storage::load_config(config_path, config)) {
|
||||
// output default config using heredoc to config_path
|
||||
std::ofstream config_file(config_path);
|
||||
config_file << R"END(
|
||||
{
|
||||
"write_tokens": [
|
||||
"fizzle1",
|
||||
"fizzle2",
|
||||
"fizzle3"
|
||||
],
|
||||
"object_store_path": "/home/j/.simple_object_storage/",
|
||||
"host": "0.0.0.0",
|
||||
"port": 8123
|
||||
}
|
||||
)END";
|
||||
config_file.close();
|
||||
}
|
||||
|
||||
if (!simple_object_storage::load_config(config_path, config)) {
|
||||
std::cerr << "Failed to load configuration at "<<config_path << std::endl;
|
||||
return 1;
|
||||
}
|
||||
@@ -16,11 +37,17 @@ int main(int argc, char* argv[]) {
|
||||
std::cout << "Starting server at " << config.host << ":" << config.port << std::endl;
|
||||
std::cout << "Object store path: " << config.object_store_path << std::endl;
|
||||
|
||||
dropshell::Server server(config);
|
||||
Server server(config);
|
||||
if (!server.start()) {
|
||||
std::cerr << "Failed to start server" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace simple_object_storage
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
return simple_object_storage::main(argc, argv);
|
||||
}
|
Reference in New Issue
Block a user