SIGTERM handler and minor startup improvements. (#185)

* SIGTERM handler and stderr usage.
* Create-contract state seed dir creation.
This commit is contained in:
Ravin Perera
2020-12-06 10:38:35 +05:30
committed by GitHub
parent b2fd8ae4b5
commit da0eb08512
3 changed files with 37 additions and 33 deletions

View File

@@ -79,11 +79,11 @@ void deinit()
ledger::deinit();
}
void sigint_handler(int signum)
void sig_exit_handler(int signum)
{
LOG_WARNING << "Interrupt signal (" << signum << ") received.";
deinit();
std::cout << "hpcore exiting\n";
LOG_WARNING << "hpcore exited due to signal.";
exit(signum);
}
@@ -211,8 +211,9 @@ int main(int argc, char **argv)
return -1;
}
// After initializing primary subsystems, register the SIGINT handler.
signal(SIGINT, &sigint_handler);
// After initializing primary subsystems, register the exit handler.
signal(SIGINT, &sig_exit_handler);
signal(SIGTERM, &sig_exit_handler);
// Wait until consensus thread finishes.
consensus::wait();
@@ -224,6 +225,6 @@ int main(int argc, char **argv)
}
}
std::cout << "exited normally\n";
std::cout << "hpcore exited normally.\n";
return 0;
}