Unverified Commit 16e04ed9 authored by Wang Yuan's avatar Wang Yuan Committed by GitHub
Browse files

Don't start in sentinel mode if only the folder name contains redis-sentinel (#9176)

Before this commit, redis-server starts in sentinel mode if the first startup
argument has the string redis-sentinel, so redis also starts in sentinel mode
if the directory it was started from contains the string redis-sentinel.
Now we check the executable name instead of directory.

Some examples:
1. Execute ./redis-sentinel/redis/src/redis-sentinel, starts in sentinel mode.
2. Execute ./redis-sentinel/redis/src/redis-server, starts in server mode,
   but before, redis will start in sentinel mode.
3. Execute ./redis-sentinel/redis/src/redis-server --sentinel, of course, like
   before, starts in sentinel mode.
parent 6476c8e8
...@@ -5885,12 +5885,13 @@ void sendChildInfo(childInfoType info_type, size_t keys, char *pname) { ...@@ -5885,12 +5885,13 @@ void sendChildInfo(childInfoType info_type, size_t keys, char *pname) {
void memtest(size_t megabytes, int passes); void memtest(size_t megabytes, int passes);
/* Returns 1 if there is --sentinel among the arguments or if /* Returns 1 if there is --sentinel among the arguments or if
* argv[0] contains "redis-sentinel". */ * executable name contains "redis-sentinel". */
int checkForSentinelMode(int argc, char **argv) { int checkForSentinelMode(int argc, char **argv) {
int j; char *exec_name = strrchr(argv[0], '/');
if (exec_name == NULL) exec_name = argv[0];
if (strstr(exec_name,"redis-sentinel") != NULL) return 1;
if (strstr(argv[0],"redis-sentinel") != NULL) return 1; for (int j = 1; j < argc; j++)
for (j = 1; j < argc; j++)
if (!strcmp(argv[j],"--sentinel")) return 1; if (!strcmp(argv[j],"--sentinel")) return 1;
return 0; return 0;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment