mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-08 22:13:48 +01:00
[config, daemon] catch TSTP, CONT is option
This commit is contained in:
parent
5394b747a1
commit
437282b148
2 changed files with 37 additions and 13 deletions
|
@ -60,7 +60,7 @@ void handle_signal(int sig)
|
||||||
i2p::transport::transports.SetOnline(false);
|
i2p::transport::transports.SetOnline(false);
|
||||||
break;
|
break;
|
||||||
case SIGCONT:
|
case SIGCONT:
|
||||||
LogPrint(eLogInfo, "Daemon: Got SIGCONT, restore connection to network...");
|
LogPrint(eLogInfo, "Daemon: Got SIGCONT, restoring connection to network...");
|
||||||
i2p::transport::transports.SetOnline(true);
|
i2p::transport::transports.SetOnline(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -180,6 +180,9 @@ namespace i2p
|
||||||
}
|
}
|
||||||
gracefulShutdownInterval = 0; // not specified
|
gracefulShutdownInterval = 0; // not specified
|
||||||
|
|
||||||
|
// handle signal TSTP
|
||||||
|
bool handleTSTP; i2p::config::GetOption("unix.handle_sigtstp", handleTSTP);
|
||||||
|
|
||||||
// Signal handler
|
// Signal handler
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
sa.sa_handler = handle_signal;
|
sa.sa_handler = handle_signal;
|
||||||
|
@ -191,6 +194,11 @@ namespace i2p
|
||||||
sigaction(SIGTERM, &sa, 0);
|
sigaction(SIGTERM, &sa, 0);
|
||||||
sigaction(SIGINT, &sa, 0);
|
sigaction(SIGINT, &sa, 0);
|
||||||
sigaction(SIGPIPE, &sa, 0);
|
sigaction(SIGPIPE, &sa, 0);
|
||||||
|
if (handleTSTP)
|
||||||
|
{
|
||||||
|
sigaction(SIGTSTP, &sa, 0);
|
||||||
|
sigaction(SIGCONT, &sa, 0);
|
||||||
|
}
|
||||||
|
|
||||||
return Daemon_Singleton::start();
|
return Daemon_Singleton::start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -311,6 +311,19 @@ namespace config {
|
||||||
("meshnets.yggaddress", value<std::string>()->default_value(""), "Yggdrasil address to publish")
|
("meshnets.yggaddress", value<std::string>()->default_value(""), "Yggdrasil address to publish")
|
||||||
;
|
;
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
options_description unix_specific("UNIX-specific options");
|
||||||
|
unix_specific.add_options()
|
||||||
|
("unix.handle_sigtstp", bool_switch()->default_value(false),
|
||||||
|
"Switch to offline mode if received signal TSTP (SIGTSTP)"
|
||||||
|
"(you can send it by pressing CTRL+Z in terminal or with"
|
||||||
|
" help commapnd kill and others, a.e pkill, if i2pd in "
|
||||||
|
"daemon mode). If you need to switch to online mode, send"
|
||||||
|
" signal CONT (SIGCONT)")
|
||||||
|
;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
m_OptionsDesc
|
m_OptionsDesc
|
||||||
.add(general)
|
.add(general)
|
||||||
.add(limits)
|
.add(limits)
|
||||||
|
@ -334,6 +347,9 @@ namespace config {
|
||||||
.add(persist)
|
.add(persist)
|
||||||
.add(cpuext)
|
.add(cpuext)
|
||||||
.add(meshnets)
|
.add(meshnets)
|
||||||
|
#ifdef __linux__
|
||||||
|
.add(unix_specific)
|
||||||
|
#endif
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue