From f98cb0c79a60481913eef0d970cd7b10a6407de9 Mon Sep 17 00:00:00 2001 From: Twice Date: Wed, 20 Nov 2024 01:52:43 +0800 Subject: [PATCH] feat(cmd): add more information to shutdown log (#2672) --- src/cli/main.cc | 4 ++-- src/commands/cmd_server.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cli/main.cc b/src/cli/main.cc index 9eeab518c25..11a64760755 100644 --- a/src/cli/main.cc +++ b/src/cli/main.cc @@ -47,7 +47,7 @@ Server *srv = nullptr; extern "C" void SignalHandler([[maybe_unused]] int sig) { if (srv && !srv->IsStopped()) { - LOG(INFO) << "Bye Bye"; + LOG(INFO) << "Signal " << sig << " received, stopping the server"; srv->Stop(); } } @@ -116,6 +116,7 @@ static void InitGoogleLog(const Config *config) { int main(int argc, char *argv[]) { srand(static_cast(util::GetTimeStamp())); + crc64_init(); evthread_use_pthreads(); auto event_exit = MakeScopeExit(libevent_global_shutdown); @@ -137,7 +138,6 @@ int main(int argc, char *argv[]) { } }); - crc64_init(); InitGoogleLog(&config); google::InitGoogleLogging("kvrocks"); auto glog_exit = MakeScopeExit(google::ShutdownGoogleLogging); diff --git a/src/commands/cmd_server.cc b/src/commands/cmd_server.cc index c7f742656d0..f17903c21d3 100644 --- a/src/commands/cmd_server.cc +++ b/src/commands/cmd_server.cc @@ -544,7 +544,7 @@ class CommandShutdown : public Commander { } if (!srv->IsStopped()) { - LOG(INFO) << "bye bye"; + LOG(INFO) << "SHUTDOWN command received, stopping the server"; srv->Stop(); } return Status::OK(); @@ -1344,7 +1344,7 @@ REDIS_REGISTER_COMMANDS(Server, MakeCmdAttr("auth", 2, "read-only o MakeCmdAttr("perflog", -2, "read-only", NO_KEY), MakeCmdAttr("client", -2, "read-only", NO_KEY), MakeCmdAttr("monitor", 1, "read-only no-multi no-script", NO_KEY), - MakeCmdAttr("shutdown", 1, "read-only no-multi no-script", NO_KEY), + MakeCmdAttr("shutdown", 1, "read-only exclusive no-multi no-script", NO_KEY), MakeCmdAttr("quit", 1, "read-only", NO_KEY), MakeCmdAttr("scan", -2, "read-only", NO_KEY), MakeCmdAttr("randomkey", 1, "read-only", NO_KEY),