mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-23 05:06:31 +00:00
* migration
This commit is contained in:
parent
17fb419fb1
commit
c57b13d922
@ -110,7 +110,7 @@ namespace config {
|
|||||||
("conf", value<std::string>()->default_value(""), "Path to main i2pd config file (default: try ~/.i2pd/i2p.conf or /var/lib/i2pd/i2p.conf)")
|
("conf", value<std::string>()->default_value(""), "Path to main i2pd config file (default: try ~/.i2pd/i2p.conf or /var/lib/i2pd/i2p.conf)")
|
||||||
("tunconf", value<std::string>()->default_value(""), "Path to config with tunnels list and options (default: try ~/.i2pd/tunnels.cfg or /var/lib/i2pd/tunnels.cfg)")
|
("tunconf", value<std::string>()->default_value(""), "Path to config with tunnels list and options (default: try ~/.i2pd/tunnels.cfg or /var/lib/i2pd/tunnels.cfg)")
|
||||||
("pidfile", value<std::string>()->default_value(""), "Path to pidfile (default: ~/i2pd/i2pd.pid or /var/lib/i2pd/i2pd.pid)")
|
("pidfile", value<std::string>()->default_value(""), "Path to pidfile (default: ~/i2pd/i2pd.pid or /var/lib/i2pd/i2pd.pid)")
|
||||||
("log", value<std::string>()->default_value(""), "Logs destination: stdout, file (stdout if not set, file - otherwise, for compatibility)")
|
("log", value<std::string>()->default_value(""), "Logs destination: stdout, file, syslog (stdout if not set)")
|
||||||
("logfile", value<std::string>()->default_value(""), "Path to logfile (stdout if not set, autodetect if daemon)")
|
("logfile", value<std::string>()->default_value(""), "Path to logfile (stdout if not set, autodetect if daemon)")
|
||||||
("loglevel", value<std::string>()->default_value("info"), "Set the minimal level of log messages (debug, info, warn, error)")
|
("loglevel", value<std::string>()->default_value("info"), "Set the minimal level of log messages (debug, info, warn, error)")
|
||||||
("family", value<std::string>()->default_value(""), "Specify a family, router belongs to")
|
("family", value<std::string>()->default_value(""), "Specify a family, router belongs to")
|
||||||
|
50
Daemon.cpp
50
Daemon.cpp
@ -79,17 +79,38 @@ namespace i2p
|
|||||||
i2p::config::ParseConfig(config);
|
i2p::config::ParseConfig(config);
|
||||||
i2p::config::Finalize();
|
i2p::config::Finalize();
|
||||||
|
|
||||||
i2p::crypto::InitCrypto ();
|
|
||||||
i2p::context.Init ();
|
|
||||||
|
|
||||||
i2p::config::GetOption("daemon", isDaemon);
|
i2p::config::GetOption("daemon", isDaemon);
|
||||||
|
|
||||||
// TODO: move log init here
|
std::string logs = ""; i2p::config::GetOption("log", logs);
|
||||||
|
std::string logfile = ""; i2p::config::GetOption("logfile", logfile);
|
||||||
|
std::string loglevel = ""; i2p::config::GetOption("loglevel", loglevel);
|
||||||
|
|
||||||
|
/* setup logging */
|
||||||
|
if (isDaemon && (logs == "" || logs == "stdout"))
|
||||||
|
logs = "file";
|
||||||
|
|
||||||
|
i2p::log::Logger().SetLogLevel(loglevel);
|
||||||
|
if (logs == "file") {
|
||||||
|
if (logfile == "")
|
||||||
|
logfile = i2p::fs::DataDirPath("i2pd.log");
|
||||||
|
LogPrint(eLogInfo, "Log: will send messages to ", logfile);
|
||||||
|
i2p::log::Logger().SendTo (logfile);
|
||||||
|
#ifndef _WIN32
|
||||||
|
} else if (logs == "syslog") {
|
||||||
|
LogPrint(eLogInfo, "Log: will send messages to syslog");
|
||||||
|
i2p::log::Logger().SendTo("i2pd", LOG_DAEMON);
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
// use stdout -- default
|
||||||
|
}
|
||||||
|
|
||||||
LogPrint(eLogInfo, "i2pd v", VERSION, " starting");
|
LogPrint(eLogInfo, "i2pd v", VERSION, " starting");
|
||||||
LogPrint(eLogDebug, "FS: main config file: ", config);
|
LogPrint(eLogDebug, "FS: main config file: ", config);
|
||||||
LogPrint(eLogDebug, "FS: data directory: ", datadir);
|
LogPrint(eLogDebug, "FS: data directory: ", datadir);
|
||||||
|
|
||||||
|
i2p::crypto::InitCrypto ();
|
||||||
|
i2p::context.Init ();
|
||||||
|
|
||||||
uint16_t port; i2p::config::GetOption("port", port);
|
uint16_t port; i2p::config::GetOption("port", port);
|
||||||
if (!i2p::config::IsDefault("port"))
|
if (!i2p::config::IsDefault("port"))
|
||||||
{
|
{
|
||||||
@ -152,26 +173,6 @@ namespace i2p
|
|||||||
|
|
||||||
bool Daemon_Singleton::start()
|
bool Daemon_Singleton::start()
|
||||||
{
|
{
|
||||||
std::string logs = ""; i2p::config::GetOption("log", logs);
|
|
||||||
std::string logfile = ""; i2p::config::GetOption("logfile", logfile);
|
|
||||||
std::string loglevel = ""; i2p::config::GetOption("loglevel", loglevel);
|
|
||||||
|
|
||||||
if (isDaemon && (logs == "" || logs == "stdout"))
|
|
||||||
logs = "file";
|
|
||||||
|
|
||||||
if (logs == "syslog") {
|
|
||||||
// use syslog only no stdout
|
|
||||||
StartSyslog();
|
|
||||||
} else if (logs == "file") {
|
|
||||||
if (logfile == "")
|
|
||||||
logfile = i2p::fs::DataDirPath("i2pd.log");
|
|
||||||
StartLog (logfile);
|
|
||||||
} else {
|
|
||||||
// use stdout
|
|
||||||
StartLog ("");
|
|
||||||
}
|
|
||||||
SetLogLevel(loglevel);
|
|
||||||
|
|
||||||
bool http; i2p::config::GetOption("http.enabled", http);
|
bool http; i2p::config::GetOption("http.enabled", http);
|
||||||
if (http) {
|
if (http) {
|
||||||
std::string httpAddr; i2p::config::GetOption("http.address", httpAddr);
|
std::string httpAddr; i2p::config::GetOption("http.address", httpAddr);
|
||||||
@ -236,7 +237,6 @@ namespace i2p
|
|||||||
d.m_I2PControlService = nullptr;
|
d.m_I2PControlService = nullptr;
|
||||||
}
|
}
|
||||||
i2p::crypto::TerminateCrypto ();
|
i2p::crypto::TerminateCrypto ();
|
||||||
StopLog ();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ void handle_signal(int sig)
|
|||||||
{
|
{
|
||||||
case SIGHUP:
|
case SIGHUP:
|
||||||
LogPrint(eLogInfo, "Daemon: Got SIGHUP, reopening log...");
|
LogPrint(eLogInfo, "Daemon: Got SIGHUP, reopening log...");
|
||||||
ReopenLogFile ();
|
i2p::log::Logger().Reopen ();
|
||||||
break;
|
break;
|
||||||
case SIGABRT:
|
case SIGABRT:
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
|
@ -75,7 +75,7 @@ namespace i2p
|
|||||||
i2p::config::SetOption("log", std::string ("file"));
|
i2p::config::SetOption("log", std::string ("file"));
|
||||||
#endif
|
#endif
|
||||||
bool ret = Daemon_Singleton::start();
|
bool ret = Daemon_Singleton::start();
|
||||||
if (ret && IsLogToFile ())
|
if (ret && i2p::log::Logger().GetLogType() == eLogFile)
|
||||||
{
|
{
|
||||||
// TODO: find out where this garbage to console comes from
|
// TODO: find out where this garbage to console comes from
|
||||||
SetStdHandle(STD_OUTPUT_HANDLE, INVALID_HANDLE_VALUE);
|
SetStdHandle(STD_OUTPUT_HANDLE, INVALID_HANDLE_VALUE);
|
||||||
|
5
api.cpp
5
api.cpp
@ -40,9 +40,9 @@ namespace api
|
|||||||
void StartI2P (std::shared_ptr<std::ostream> logStream)
|
void StartI2P (std::shared_ptr<std::ostream> logStream)
|
||||||
{
|
{
|
||||||
if (logStream)
|
if (logStream)
|
||||||
StartLog (logStream);
|
i2p::log::Logger().SendTo (logStream);
|
||||||
else
|
else
|
||||||
StartLog (i2p::fs::DataDirPath (i2p::fs::GetAppName () + ".log"));
|
i2p::log::Logger().SendTo (i2p::fs::DataDirPath (i2p::fs::GetAppName () + ".log"));
|
||||||
LogPrint(eLogInfo, "API: starting NetDB");
|
LogPrint(eLogInfo, "API: starting NetDB");
|
||||||
i2p::data::netdb.Start();
|
i2p::data::netdb.Start();
|
||||||
LogPrint(eLogInfo, "API: starting Transports");
|
LogPrint(eLogInfo, "API: starting Transports");
|
||||||
@ -60,7 +60,6 @@ namespace api
|
|||||||
i2p::transport::transports.Stop();
|
i2p::transport::transports.Stop();
|
||||||
LogPrint(eLogInfo, "API: stopping NetDB");
|
LogPrint(eLogInfo, "API: stopping NetDB");
|
||||||
i2p::data::netdb.Stop();
|
i2p::data::netdb.Stop();
|
||||||
StopLog ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunPeerTest ()
|
void RunPeerTest ()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user