some useful log statements

This commit is contained in:
Thomas Winget 2022-10-27 11:00:40 -04:00
parent 9cdfae2e42
commit 7ddad87dbf
2 changed files with 8 additions and 1 deletions

View File

@ -34,12 +34,14 @@ SERVICE_STATUS_HANDLE SvcStatusHandle;
bool start_as_daemon = false;
#endif
static auto logcat = llarp::log::Cat("main");
std::shared_ptr<llarp::Context> ctx;
std::promise<int> exit_code;
void
handle_signal(int sig)
{
llarp::log::info(logcat, "Handling signal {}", sig);
if (ctx)
ctx->loop->call([sig] { ctx->HandleSignal(sig); });
else
@ -647,7 +649,8 @@ SvcCtrlHandler(DWORD dwCtrl)
switch (dwCtrl)
{
case SERVICE_CONTROL_STOP:
// tell servicve we are stopping
// tell service we are stopping
llarp::log::info(logcat, "Windows service controller gave SERVICE_CONTROL_STOP");
ReportSvcStatus(SERVICE_STOP_PENDING, NO_ERROR, 0);
// do the actual tear down
handle_signal(SIGINT);

View File

@ -20,6 +20,8 @@
#include <pthread_np.h>
#endif
static auto logcat = llarp::log::Cat("llarp-context");
namespace llarp
{
bool
@ -159,6 +161,7 @@ namespace llarp
void
Context::HandleSignal(int sig)
{
llarp::log::debug(logcat, "Handling signal {}", sig);
if (sig == SIGINT || sig == SIGTERM)
{
SigINT();
@ -188,6 +191,7 @@ namespace llarp
{
if (router)
{
llarp::log::debug(logcat, "Handling SIGINT");
/// async stop router on sigint
router->Stop();
}