Browse Source

daemon: make possible to set datadir before init

Signed-off-by: R4SAS <r4sas@i2pmail.org>
pull/1752/head
R4SAS 3 years ago
parent
commit
2f10decf56
  1. 14
      daemon/Daemon.cpp
  2. 18
      daemon/Daemon.h

14
daemon/Daemon.cpp

@ -64,6 +64,12 @@ namespace util @@ -64,6 +64,12 @@ namespace util
return service;
}
void Daemon_Singleton::setDataDir(std::string path)
{
if (path != "")
DaemonDataDir = path;
}
bool Daemon_Singleton::init(int argc, char* argv[]) {
return init(argc, argv, nullptr);
}
@ -74,7 +80,13 @@ namespace util @@ -74,7 +80,13 @@ namespace util
i2p::config::ParseCmdline(argc, argv);
std::string config; i2p::config::GetOption("conf", config);
std::string datadir; i2p::config::GetOption("datadir", datadir);
std::string datadir;
if(DaemonDataDir != "") {
datadir = DaemonDataDir;
} else {
i2p::config::GetOption("datadir", datadir);
}
i2p::fs::DetectDataDir(datadir, IsService());
i2p::fs::Init();

18
daemon/Daemon.h

@ -22,25 +22,31 @@ namespace util @@ -22,25 +22,31 @@ namespace util
{
public:
virtual bool init(int argc, char* argv[], std::shared_ptr<std::ostream> logstream);
virtual bool init(int argc, char* argv[]);
virtual bool start();
virtual bool stop();
virtual bool init (int argc, char* argv[], std::shared_ptr<std::ostream> logstream);
virtual bool init (int argc, char* argv[]);
virtual bool start ();
virtual bool stop ();
virtual void run () {};
virtual void setDataDir (std::string path);
bool isDaemon;
bool running;
protected:
Daemon_Singleton();
virtual ~Daemon_Singleton();
Daemon_Singleton ();
virtual ~Daemon_Singleton ();
bool IsService () const;
// d-pointer for httpServer, httpProxy, etc.
class Daemon_Singleton_Private;
Daemon_Singleton_Private &d;
private:
std::string DaemonDataDir;
};
#if defined(QT_GUI_LIB) // check if QT

Loading…
Cancel
Save