diff --git a/src/redis.c b/src/redis.c index 60195ab8c6c7143f582a4bec3b8e7d1a194f6f13..0778223e64baf639bd603c7969be300cb893c8e5 100644 --- a/src/redis.c +++ b/src/redis.c @@ -3012,7 +3012,7 @@ int main(int argc, char **argv) { if (server.sofd > 0) redisLog(REDIS_NOTICE,"The server is now ready to accept connections at %s", server.unixsocket); } else { - redisLog(REDIS_WARNING,"Sentinel runid is %s", server.runid); + sentinelIsRunning(); } /* Warning the user about suspicious maxmemory setting. */ diff --git a/src/redis.h b/src/redis.h index eb9d9e0794b9674e4fd3a923068b0f96b3cc49a6..7ef79cc68884cf6863457e71d4e3e3a1c4ecb52a 100644 --- a/src/redis.h +++ b/src/redis.h @@ -1187,6 +1187,7 @@ void initSentinelConfig(void); void initSentinel(void); void sentinelTimer(void); char *sentinelHandleConfiguration(char **argv, int argc); +void sentinelIsRunning(void); /* Scripting */ void scriptingInit(void); diff --git a/src/sentinel.c b/src/sentinel.c index d9ffe7cbfebcf614ef373342afe173a274c64d12..e6efa7ea7219dd0d2b856715cc7f7068a86d2931 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -415,6 +415,17 @@ void initSentinel(void) { sentinel.scripts_queue = listCreate(); } +/* This function gets called when the server is in Sentinel mode, started, + * loaded the configuration, and is ready for normal operations. */ +void sentinelIsRunning(void) { + redisLog(REDIS_WARNING,"Sentinel runid is %s", server.runid); + + if (server.configfile == NULL || access(server.configfile,W_OK) == -1) { + redisLog(REDIS_WARNING,"Sentinel started without a config file, or config file not writable. Exiting..."); + exit(1); + } +} + /* ============================== sentinelAddr ============================== */ /* Create a sentinelAddr object and return it on success. @@ -2071,7 +2082,7 @@ int sentinelSendHello(sentinelRedisInstance *ri) { /* Try to obtain our own IP address. */ if (anetSockName(ri->cc->c.fd,ip,sizeof(ip),NULL) == -1) return REDIS_ERR; - if (ri->flags & SRI_DISCONNECTED) return; + if (ri->flags & SRI_DISCONNECTED) return REDIS_ERR; /* Format and send the Hello message. */ snprintf(payload,sizeof(payload),