Describe the bug

QQ20210617-142514@2x

redis启动命令的目录如果存在sentinel关键字,redis-server启动将会变为sentinel模式, 而不是通过增加--sentienl关键字来控制

If the sentinel keyword exists in the directory of the redis startup command, the redis-server startup will change to sentinel mode.

Instead of adding the --sentienl keyword to control

Comment From: lowezheng

If the sentinel keyword exists in the directory of the redis startup command, the redis-server startup will change to sentinel mode.

Instead of adding the --sentienl keyword to control

Comment From: ShooterIT

Yes, in redis, we check sentinel mode by --sentinel and redis-sentinel name

/* Returns 1 if there is --sentinel among the arguments or if
 * argv[0] contains "redis-sentinel". */
int checkForSentinelMode(int argc, char **argv) {
    int j;

    if (strstr(argv[0],"redis-sentinel") != NULL) return 1;
    for (j = 1; j < argc; j++)
        if (!strcmp(argv[j],"--sentinel")) return 1;
    return 0;
}

In order to let others know your questions, please try to use English, maybe google translation can help you

Comment From: lowezheng

English description has been added in orginal question。

In this scenario, only the program path directory contains redis-sentinel, not the program that starts redis-sentinel.

i think redis startup path is likely to use the sentinel keyword, Suggest using more accurate logical judgments to identify the sentinel mode

Comment From: ShooterIT

So you hope that the redis starts as a sentinel only if the binary name contains redis-sentinel keyword instead of total argv[0], right?

Could you also translate this issue title to English?

Comment From: lowezheng

There are three start command situations

1: /opt/redis-sentinel/redis-6.2.4/src/redis-server

Actual state : work as sentinel Hope state: work as server

(The result of this command is that server mode may be more suitable, but it is actually sentinel mode )

2./opt/redis-sentinel/redis-6.2.4/src/redis-sentinel

Actual state : work as sentinel Hope state: work as sentinel

  1. /opt/redis-sentinel/redis-6.2.4/src/redis-server --sentinel

Actual state : work as sentinel Hope state: work as sentinel

Comment From: ShooterIT

/* Returns 1 if there is --sentinel among the arguments or if
 * program name contains "redis-sentinel". */
int checkForSentinelMode(int argc, char **argv) {
    int j;
    char *program_name = strrchr(argv[0], '/');
    if (program_name == NULL) program_name = argv[0];
    if (strstr(program_name,"redis-sentinel") != NULL) return 1;
    for (j = 1; j < argc; j++)
        if (!strcmp(argv[j],"--sentinel")) return 1;
    return 0;
}

Oh, i also mean we should check program name instead of entire argv[0] if we don't start with "--sentinel". one draft is like above. Maybe this looks better than before, but there is a problem, maybe some operation engineers use this "feature" to deploy sentinel. @redis/core-team WDYT?

Comment From: oranagra

@ShooterIT i think what you suggest (checking just the executable name, without folders) is right (that was probably the intention). do note that it could be a breaking change in some way, maybe someone relies on putting redis in a folder with that name. but we can certainly break that minor assumption in 7.0.

Comment From: ShooterIT

do note that it could be a breaking change in some way, maybe someone relies on putting redis in a folder with that name.

Yes, this is my worry even though it is unusual.

but we can certainly break that minor assumption in 7.0.

We need to say somethings in release notes, so let me make a PR?

Comment From: oranagra

yeah, make a PR, and label it with the release-note flag.

Comment From: ShooterIT

Fixed in #9176