From 08cc5b180eb7fd573326eb538a212b4c5d54e866 Mon Sep 17 00:00:00 2001 From: Tyler Karaszewski Date: Wed, 5 Jun 2024 15:51:50 -0700 Subject: [PATCH 1/2] Save logline at shutdown --- main.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main.cpp b/main.cpp index b8eacd917..c4f3354e8 100644 --- a/main.cpp +++ b/main.cpp @@ -4,6 +4,7 @@ /// #include #include +#include #include #include #include @@ -399,5 +400,14 @@ int main(int argc, char* argv[]) { // All done SINFO("Graceful process shutdown complete"); + + // Save that we're shutting down. + pid_t pid = getpid(); + ofstream file("/var/log/bedrock_shutdown", std::ios::app); + if (file) { + file << "shutdown " << pid << " " << SComposeTime("%Y-%m-%dT%H:%M:%S", STimeNow()) << endl; + file.close(); + } + return 0; } From 881b650870468eae0e8ae3f429938d380eb271a9 Mon Sep 17 00:00:00 2001 From: Tyler Karaszewski Date: Wed, 5 Jun 2024 15:57:32 -0700 Subject: [PATCH 2/2] Shorter version --- main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index c4f3354e8..ff6ef35b4 100644 --- a/main.cpp +++ b/main.cpp @@ -402,10 +402,9 @@ int main(int argc, char* argv[]) { SINFO("Graceful process shutdown complete"); // Save that we're shutting down. - pid_t pid = getpid(); ofstream file("/var/log/bedrock_shutdown", std::ios::app); if (file) { - file << "shutdown " << pid << " " << SComposeTime("%Y-%m-%dT%H:%M:%S", STimeNow()) << endl; + file << "shutdown " << getpid() << " " << SComposeTime("%Y-%m-%dT%H:%M:%S", STimeNow()) << endl; file.close(); }