mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Shutdown cleanly on control-C.
This commit is contained in:
@@ -71,8 +71,24 @@ static void InitDB(DatabaseCon** dbCon, const char *fileName, const char *dbInit
|
|||||||
*dbCon = new DatabaseCon(fileName, dbInit, dbCount);
|
*dbCon = new DatabaseCon(fileName, dbInit, dbCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
volatile bool doShutdown = false;
|
||||||
|
|
||||||
|
#ifdef SIGINT
|
||||||
|
void sigIntHandler(int)
|
||||||
|
{
|
||||||
|
doShutdown = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void Application::run()
|
void Application::run()
|
||||||
{
|
{
|
||||||
|
#ifdef SIGINT
|
||||||
|
struct sigaction sa;
|
||||||
|
memset(&sa, 0, sizeof(sa));
|
||||||
|
sa.sa_handler = sigIntHandler;
|
||||||
|
sigaction(SIGINT, &sa, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
assert(mTxnDB == NULL);
|
assert(mTxnDB == NULL);
|
||||||
if (!theConfig.DEBUG_LOGFILE.empty())
|
if (!theConfig.DEBUG_LOGFILE.empty())
|
||||||
{ // Let DEBUG messages go to the file but only WARNING or higher to regular output (unless verbose)
|
{ // Let DEBUG messages go to the file but only WARNING or higher to regular output (unless verbose)
|
||||||
|
|||||||
@@ -644,8 +644,16 @@ void LedgerConsensus::stateAccepted()
|
|||||||
endConsensus();
|
endConsensus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern volatile bool doShutdown;
|
||||||
|
|
||||||
void LedgerConsensus::timerEntry()
|
void LedgerConsensus::timerEntry()
|
||||||
{
|
{
|
||||||
|
if (doShutdown)
|
||||||
|
{
|
||||||
|
cLog(lsFATAL) << "Shutdown requested";
|
||||||
|
theApp->stop();
|
||||||
|
}
|
||||||
|
|
||||||
if ((mState != lcsFINISHED) && (mState != lcsACCEPTED))
|
if ((mState != lcsFINISHED) && (mState != lcsACCEPTED))
|
||||||
checkLCL();
|
checkLCL();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user