Use libsystemd's sd_notify for communicating redis status to systemd

Instead of replicating a subset of libsystemd's sd_notify(3) internally,
use the dynamic library provided by systemd to communicate with the
service manager.

When systemd supervision was auto-detected or configured, communicate
the actual server status (i.e. "Loading dataset", "Waiting for
master<->replica sync") to systemd, instead of declaring readiness right
after initializing the server process.
This commit is contained in:
Johannes Truschnigg
2019-04-27 18:07:30 +02:00
committed by max ulidtko
parent 45025713a8
commit 641c64ada1
3 changed files with 51 additions and 45 deletions

View File

@ -1665,6 +1665,11 @@ void readSyncBulkPayload(connection *conn) {
if (server.repl_backlog == NULL) createReplicationBacklog();
serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: Finished with success");
if (server.supervised_mode == SUPERVISED_SYSTEMD) {
redisCommunicateSystemd("STATUS=MASTER <-> REPLICA sync: Finished with success. Ready to accept connections.\n");
redisCommunicateSystemd("READY=1\n");
}
/* Restart the AOF subsystem now that we finished the sync. This
* will trigger an AOF rewrite, and when done will start appending
* to the new file. */