Skip to content

Commit

Permalink
Merge pull request #1773 from Expensify/main
Browse files Browse the repository at this point in the history
Update expensify_prod branch
  • Loading branch information
madmax330 authored Jun 11, 2024
2 parents 45f6098 + 358d147 commit 823c9f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 10 additions & 0 deletions BedrockServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <arpa/inet.h>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <sys/resource.h>
#include <sys/time.h>
Expand Down Expand Up @@ -621,6 +622,15 @@ void BedrockServer::sync()
// until they return.
atomic_store(&_syncNode, shared_ptr<SQLiteNode>(nullptr));

// If we're not detaching, save that we're shutting down.
if (!_detach) {
ofstream file("/var/log/bedrock_shutdown", std::ios::app);
if (file) {
file << "shutdown " << getpid() << " " << SComposeTime("%Y-%m-%dT%H:%M:%S", STimeNow()) << endl;
file.close();
}
}

// Release the current DB pool, and zero out our pointer. If any socket threads hold a handle to `_syncNode`, they will keep this in existence
// until they release it.
_dbPool = nullptr;
Expand Down
7 changes: 0 additions & 7 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
///
#include <dlfcn.h>
#include <iostream>
#include <fstream>
#include <signal.h>
#include <sys/resource.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -401,12 +400,6 @@ int main(int argc, char* argv[]) {
// All done
SINFO("Graceful process shutdown complete");

// Save that we're shutting down.
ofstream file("/var/log/bedrock_shutdown", std::ios::app);
if (file) {
file << "shutdown " << getpid() << " " << SComposeTime("%Y-%m-%dT%H:%M:%S", STimeNow()) << endl;
file.close();
}

return 0;
}

0 comments on commit 823c9f7

Please sign in to comment.