Fix Context::Configure()

This commit is contained in:
Stephen Shelton 2020-07-01 16:46:32 -06:00
parent 343252c48d
commit ec20d94c6b
No known key found for this signature in database
GPG Key ID: EE4BADACCE8B631C
5 changed files with 10 additions and 7 deletions

View File

@ -99,7 +99,7 @@ run_main_context(const fs::path confFile, const llarp::RuntimeOptions opts)
conf.Load(confFile, opts.isRouter, confFile.parent_path());
ctx = std::make_shared<llarp::Context>();
ctx->Configure(opts, {});
ctx->Configure(opts, {}, confFile);
signal(SIGINT, handle_signal);
signal(SIGTERM, handle_signal);

View File

@ -60,7 +60,8 @@ namespace llarp
HandleSignal(int sig);
bool
Configure(const RuntimeOptions& opts, std::optional<fs::path> dataDir);
Configure(
const RuntimeOptions& opts, std::optional<fs::path> dataDir, const fs::path& configfile);
bool
IsUp() const;
@ -94,7 +95,6 @@ namespace llarp
void
SigINT();
std::string configfile;
std::unique_ptr<std::promise<void>> closeWaiter;
};

View File

@ -28,14 +28,17 @@ namespace llarp
}
bool
Context::Configure(const RuntimeOptions& opts, std::optional<fs::path> dataDir)
Context::Configure(
const RuntimeOptions& opts, std::optional<fs::path> dataDir, const fs::path& configfile)
{
LogWarn("Context::Configure()");
if (nullptr == config.get())
config = std::make_unique<Config>();
fs::path defaultDataDir = dataDir ? *dataDir : GetDefaultDataDir();
if (configfile.size())
if (not configfile.empty())
{
if (!config->Load(configfile.c_str(), opts.isRouter, defaultDataDir))
{

View File

@ -23,7 +23,7 @@ namespace tooling
Context_ptr context = std::make_shared<HiveContext>(this);
context->config = std::make_unique<llarp::Config>(*config.get());
context->Configure(opts, {});
context->Configure(opts, {}, {});
context->Setup(opts);
auto routerId = llarp::RouterID(context->router->pubkey());

View File

@ -12,7 +12,7 @@ static std::shared_ptr<llarp::Context>
make_context(std::optional<fs::path> keyfile)
{
auto context = std::make_shared<llarp::Context>();
context->Configure(opts, {});
context->Configure(opts, {}, {});
context->config->network.m_endpointType = "null";
context->config->network.m_keyfile = keyfile;