Remove pidfile support

pull/1186/head
Stephen Shelton 4 years ago
parent 4f77080f75
commit f250b7adcb
No known key found for this signature in database
GPG Key ID: EE4BADACCE8B631C

@ -101,21 +101,12 @@ namespace llarp
#endif
private:
void
SetPIDFile(const std::string& fname);
bool
WritePIDFile() const;
void
RemovePIDFile() const;
void
SigINT();
std::string configfile;
std::string pidfile;
std::unique_ptr<std::promise<void>> closeWaiter;
std::unique_ptr< std::promise< void > > closeWaiter;
};
} // namespace llarp

@ -267,16 +267,6 @@ namespace llarp
});
}
void
SystemConfig::defineConfigOptions(Configuration& conf, const ConfigGenParameters& params)
{
(void)params;
// TODO: remove in favor of deriving from [router]:data-dir
conf.defineOption<std::string>("system", "pidfile", false, pidfile,
AssignmentAcceptor(pidfile));
}
void
ApiConfig::defineConfigOptions(Configuration& conf, const ConfigGenParameters& params)
{
@ -491,7 +481,6 @@ namespace llarp
dns.defineConfigOptions(conf, params);
links.defineConfigOptions(conf, params);
services.defineConfigOptions(conf, params);
system.defineConfigOptions(conf, params);
api.defineConfigOptions(conf, params);
lokid.defineConfigOptions(conf, params);
bootstrap.defineConfigOptions(conf, params);
@ -625,15 +614,6 @@ namespace llarp
def.addOptionComment("api", "bind", "IP address and port to bind to.");
def.addOptionComment("api", "bind", "Recommend localhost-only for security purposes.");
// system
def.addSectionComment("system", "System setings for running lokinet.");
def.addOptionComment("system", "user", "The user which lokinet should run as.");
def.addOptionComment("system", "group", "The group which lokinet should run as.");
def.addOptionComment("system", "pidfile", "Location of the pidfile for lokinet.");
// dns
def.addSectionComment("dns", "DNS configuration");

@ -118,14 +118,6 @@ namespace llarp
defineConfigOptions(Configuration& conf, const ConfigGenParameters& params);
};
struct SystemConfig
{
std::string pidfile;
void
defineConfigOptions(Configuration& conf, const ConfigGenParameters& params);
};
struct ApiConfig
{
bool m_enableRPCServer;
@ -199,7 +191,6 @@ namespace llarp
DnsConfig dns;
LinksConfig links;
ServicesConfig services;
SystemConfig system;
ApiConfig api;
LokidConfig lokid;
BootstrapConfig bootstrap;

@ -44,11 +44,6 @@ namespace llarp
}
}
// System config
if (!config->system.pidfile.empty())
{
SetPIDFile(config->system.pidfile);
}
auto threads = config->router.m_workerThreads;
if(threads <= 0)
threads = 1;
@ -64,12 +59,6 @@ namespace llarp
return true;
}
void
Context::SetPIDFile(const std::string& fname)
{
pidfile = fname;
}
bool
Context::IsUp() const
{
@ -135,8 +124,6 @@ namespace llarp
llarp::LogError("cannot run non configured context");
return 1;
}
if (!WritePIDFile())
return 1;
// run
if (!router->StartJsonRpc())
return 1;
@ -179,34 +166,6 @@ namespace llarp
}
}
bool
Context::WritePIDFile() const
{
if (pidfile.size())
{
std::ofstream f(pidfile);
f << std::to_string(getpid());
return f.good();
}
return true;
}
void
Context::RemovePIDFile() const
{
if (pidfile.size())
{
fs::path f = pidfile;
std::error_code ex;
if (fs::exists(f, ex))
{
if (!ex)
fs::remove(f);
}
}
}
void
Context::HandleSignal(int sig)
{
@ -256,8 +215,6 @@ namespace llarp
llarp::LogDebug("free logic");
logic.reset();
RemovePIDFile();
}
bool

Loading…
Cancel
Save