MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / sentinelIsRunning

Function sentinelIsRunning

src/sentinel.cpp:571–592  ·  view source on GitHub ↗

This function gets called when the server is in Sentinel mode, started, * loaded the configuration, and is ready for normal operations. */

Source from the content-addressed store, hash-verified

569/* This function gets called when the server is in Sentinel mode, started,
570 * loaded the configuration, and is ready for normal operations. */
571void sentinelIsRunning(void) {
572 int j;
573
574 /* If this Sentinel has yet no ID set in the configuration file, we
575 * pick a random one and persist the config on disk. From now on this
576 * will be this Sentinel ID across restarts. */
577 for (j = 0; j < CONFIG_RUN_ID_SIZE; j++)
578 if (sentinel.myid[j] != 0) break;
579
580 if (j == CONFIG_RUN_ID_SIZE) {
581 /* Pick ID and persist the config. */
582 getRandomHexChars(sentinel.myid,CONFIG_RUN_ID_SIZE);
583 sentinelFlushConfig();
584 }
585
586 /* Log its ID to make debugging of issues simpler. */
587 serverLog(LL_WARNING,"Sentinel ID is %s", sentinel.myid);
588
589 /* We want to generate a +monitor event for every configured master
590 * at startup. */
591 sentinelGenerateInitialMonitorEvents();
592}
593
594/* ============================== sentinelAddr ============================== */
595

Callers 1

mainFunction · 0.85

Calls 4

getRandomHexCharsFunction · 0.85
sentinelFlushConfigFunction · 0.85
serverLogFunction · 0.85

Tested by

no test coverage detected