mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Solves issue #194 on Google Code: --help parameter to redis-srver prints the usage message
This commit is contained in:
parent
c77169b7e9
commit
723fb69b9e
20
redis.c
20
redis.c
@ -799,6 +799,8 @@ static struct redisCommand cmdTable[] = {
|
|||||||
{NULL,NULL,0,0,NULL,0,0,0}
|
{NULL,NULL,0,0,NULL,0,0,0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void usage();
|
||||||
|
|
||||||
/*============================ Utility functions ============================ */
|
/*============================ Utility functions ============================ */
|
||||||
|
|
||||||
/* Glob-style pattern matching. */
|
/* Glob-style pattern matching. */
|
||||||
@ -1614,12 +1616,15 @@ static void loadServerConfig(char *filename) {
|
|||||||
char buf[REDIS_CONFIGLINE_MAX+1], *err = NULL;
|
char buf[REDIS_CONFIGLINE_MAX+1], *err = NULL;
|
||||||
int linenum = 0;
|
int linenum = 0;
|
||||||
sds line = NULL;
|
sds line = NULL;
|
||||||
|
char *errormsg = "Fatal error, can't open config file '%s'";
|
||||||
|
char *errorbuf = zmalloc(sizeof(char)*(strlen(errormsg)+strlen(filename)));
|
||||||
|
sprintf(errorbuf, errormsg, filename);
|
||||||
|
|
||||||
if (filename[0] == '-' && filename[1] == '\0')
|
if (filename[0] == '-' && filename[1] == '\0')
|
||||||
fp = stdin;
|
fp = stdin;
|
||||||
else {
|
else {
|
||||||
if ((fp = fopen(filename,"r")) == NULL) {
|
if ((fp = fopen(filename,"r")) == NULL) {
|
||||||
redisLog(REDIS_WARNING,"Fatal error, can't open config file");
|
redisLog(REDIS_WARNING, errorbuf);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9122,16 +9127,23 @@ static void daemonize(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void usage() {
|
||||||
|
fprintf(stderr,"Usage: ./redis-server [/path/to/redis.conf]\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
time_t start;
|
time_t start;
|
||||||
|
|
||||||
initServerConfig();
|
initServerConfig();
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
|
if (strcmp(argv[1], "--help") == 0) {
|
||||||
|
usage();
|
||||||
|
}
|
||||||
resetServerSaveParams();
|
resetServerSaveParams();
|
||||||
loadServerConfig(argv[1]);
|
loadServerConfig(argv[1]);
|
||||||
} else if (argc > 2) {
|
} else if ((argc > 2)) {
|
||||||
fprintf(stderr,"Usage: ./redis-server [/path/to/redis.conf]\n");
|
usage();
|
||||||
exit(1);
|
|
||||||
} else {
|
} else {
|
||||||
redisLog(REDIS_WARNING,"Warning: no config file specified, using the default config. In order to specify a config file use 'redis-server /path/to/redis.conf'");
|
redisLog(REDIS_WARNING,"Warning: no config file specified, using the default config. In order to specify a config file use 'redis-server /path/to/redis.conf'");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user