Browse Source

Merge pull request #694 from lehitoskin/graceful-typo

gracefull -> graceful
pull/697/head
orignal 8 years ago committed by GitHub
parent
commit
ef3030abe5
  1. 2
      Daemon.h
  2. 14
      DaemonLinux.cpp
  3. 14
      HTTPServer.cpp

2
Daemon.h

@ -97,7 +97,7 @@ namespace i2p
public: public:
int gracefullShutdownInterval; // in seconds int gracefulShutdownInterval; // in seconds
}; };
#endif #endif

14
DaemonLinux.cpp

@ -25,11 +25,11 @@ void handle_signal(int sig)
i2p::client::context.ReloadConfig(); i2p::client::context.ReloadConfig();
break; break;
case SIGINT: case SIGINT:
if (i2p::context.AcceptsTunnels () && !Daemon.gracefullShutdownInterval) if (i2p::context.AcceptsTunnels () && !Daemon.gracefulShutdownInterval)
{ {
i2p::context.SetAcceptsTunnels (false); i2p::context.SetAcceptsTunnels (false);
Daemon.gracefullShutdownInterval = 10*60; // 10 minutes Daemon.gracefulShutdownInterval = 10*60; // 10 minutes
LogPrint(eLogInfo, "Graceful shutdown after ", Daemon.gracefullShutdownInterval, " seconds"); LogPrint(eLogInfo, "Graceful shutdown after ", Daemon.gracefulShutdownInterval, " seconds");
} }
else else
Daemon.running = 0; Daemon.running = 0;
@ -110,7 +110,7 @@ namespace i2p
return false; return false;
} }
} }
gracefullShutdownInterval = 0; // not specified gracefulShutdownInterval = 0; // not specified
// Signal handler // Signal handler
struct sigaction sa; struct sigaction sa;
@ -137,10 +137,10 @@ namespace i2p
while (running) while (running)
{ {
std::this_thread::sleep_for (std::chrono::seconds(1)); std::this_thread::sleep_for (std::chrono::seconds(1));
if (gracefullShutdownInterval) if (gracefulShutdownInterval)
{ {
gracefullShutdownInterval--; // - 1 second gracefulShutdownInterval--; // - 1 second
if (gracefullShutdownInterval <= 0) if (gracefulShutdownInterval <= 0)
{ {
LogPrint(eLogInfo, "Graceful shutdown"); LogPrint(eLogInfo, "Graceful shutdown");
return; return;

14
HTTPServer.cpp

@ -196,7 +196,7 @@ namespace http {
} }
s << "<br>\r\n"; s << "<br>\r\n";
#if (!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID)) #if (!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID))
if (auto remains = Daemon.gracefullShutdownInterval) { if (auto remains = Daemon.gracefulShutdownInterval) {
s << "<b>Stopping in:</b> "; s << "<b>Stopping in:</b> ";
s << remains << " seconds"; s << remains << " seconds";
s << "<br>\r\n"; s << "<br>\r\n";
@ -416,13 +416,13 @@ namespace http {
else else
s << " <a href=\"/?cmd=" << HTTP_COMMAND_ENABLE_TRANSIT << "\">Accept transit tunnels</a><br>\r\n"; s << " <a href=\"/?cmd=" << HTTP_COMMAND_ENABLE_TRANSIT << "\">Accept transit tunnels</a><br>\r\n";
#if (!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID)) #if (!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID))
if (Daemon.gracefullShutdownInterval) if (Daemon.gracefulShutdownInterval)
s << " <a href=\"/?cmd=" << HTTP_COMMAND_SHUTDOWN_CANCEL << "\">Cancel gracefull shutdown</a><br>"; s << " <a href=\"/?cmd=" << HTTP_COMMAND_SHUTDOWN_CANCEL << "\">Cancel graceful shutdown</a><br>";
else else
s << " <a href=\"/?cmd=" << HTTP_COMMAND_SHUTDOWN_START << "\">Start gracefull shutdown</a><br>\r\n"; s << " <a href=\"/?cmd=" << HTTP_COMMAND_SHUTDOWN_START << "\">Start graceful shutdown</a><br>\r\n";
#endif #endif
#ifdef WIN32_APP #ifdef WIN32_APP
s << " <a href=\"/?cmd=" << HTTP_COMMAND_SHUTDOWN_START << "\">Gracefull shutdown</a><br>\r\n"; s << " <a href=\"/?cmd=" << HTTP_COMMAND_SHUTDOWN_START << "\">Graceful shutdown</a><br>\r\n";
#endif #endif
s << " <a href=\"/?cmd=" << HTTP_COMMAND_SHUTDOWN_NOW << "\">Force shutdown</a><br>\r\n"; s << " <a href=\"/?cmd=" << HTTP_COMMAND_SHUTDOWN_NOW << "\">Force shutdown</a><br>\r\n";
} }
@ -755,7 +755,7 @@ namespace http {
else if (cmd == HTTP_COMMAND_SHUTDOWN_START) { else if (cmd == HTTP_COMMAND_SHUTDOWN_START) {
i2p::context.SetAcceptsTunnels (false); i2p::context.SetAcceptsTunnels (false);
#if (!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID)) #if (!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID))
Daemon.gracefullShutdownInterval = 10*60; Daemon.gracefulShutdownInterval = 10*60;
#endif #endif
#ifdef WIN32_APP #ifdef WIN32_APP
i2p::win32::GracefulShutdown (); i2p::win32::GracefulShutdown ();
@ -763,7 +763,7 @@ namespace http {
} else if (cmd == HTTP_COMMAND_SHUTDOWN_CANCEL) { } else if (cmd == HTTP_COMMAND_SHUTDOWN_CANCEL) {
i2p::context.SetAcceptsTunnels (true); i2p::context.SetAcceptsTunnels (true);
#if (!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID)) #if (!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID))
Daemon.gracefullShutdownInterval = 0; Daemon.gracefulShutdownInterval = 0;
#endif #endif
} else if (cmd == HTTP_COMMAND_SHUTDOWN_NOW) { } else if (cmd == HTTP_COMMAND_SHUTDOWN_NOW) {
Daemon.running = false; Daemon.running = false;

Loading…
Cancel
Save