diff options
author | Binbin <binloveplay1314@qq.com> | 2022-12-06 17:12:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-06 11:12:51 +0200 |
commit | 8f13ac10b46de0c6f3cb9fd5c9e86824aa1e8355 (patch) | |
tree | 627c8cf976acfcc968c2d74c20db5c044147a5b0 /src/server.c | |
parent | e48ac075c053c39d3f7ed4d86deb6554b7d97e1a (diff) | |
download | redis-8f13ac10b46de0c6f3cb9fd5c9e86824aa1e8355.tar.gz |
Fix command line startup --sentinel problem (#11591)
There is a issue with --sentinel:
```
[root]# src/redis-server sentinel.conf --sentinel --loglevel verbose
*** FATAL CONFIG FILE ERROR (Redis 255.255.255) ***
Reading the configuration file, at line 352
>>> 'sentinel "--loglevel" "verbose"'
Unrecognized sentinel configuration statement
```
This is because in #10660 (Redis 7.0.1), `--` prefix change break it.
In this PR, we will handle `--sentinel` the same as we did for `--save`
in #10866. i.e. it's a pseudo config option with no value.
Diffstat (limited to 'src/server.c')
-rw-r--r-- | src/server.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/server.c b/src/server.c index 52ce3d4d7..7bc320795 100644 --- a/src/server.c +++ b/src/server.c @@ -7024,6 +7024,24 @@ int main(int argc, char **argv) { * so it will become `--save ""` and will follow the same reset thing. */ options = sdscat(options, "\"\""); } + else if ((j != argc-1) && argv[j+1][0] == '-' && argv[j+1][1] == '-' && + !strcasecmp(argv[j], "--sentinel")) + { + /* Special case: handle some things like `--sentinel --config value`. + * It is a pseudo config option with no value. In this case, if next + * argument starts with `--`, we will reset handled_last_config_arg flag. + * We are doing it to be compatible with pre 7.0 behavior (which we + * break it in #10660, 7.0.1). */ + options = sdscat(options, ""); + handled_last_config_arg = 1; + } + else if ((j == argc-1) && !strcasecmp(argv[j], "--sentinel")) { + /* Special case: when --sentinel is the last argument. + * It is a pseudo config option with no value. In this case, do nothing. + * We are doing it to be compatible with pre 7.0 behavior (which we + * break it in #10660, 7.0.1). */ + options = sdscat(options, ""); + } } else { /* Means that we are passing both config name and it's value in the same arg, * like "--port 6380", so we need to reset handled_last_config_arg flag. */ |