Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
c9a111ac
Commit
c9a111ac
authored
Jun 10, 2009
by
antirez
Browse files
It is now possible to specify - as config file name to read it from stdin
parent
0df1ead7
Changes
2
Hide whitespace changes
Inline
Side-by-side
client-libraries/ruby/lib/redis.rb
View file @
c9a111ac
...
@@ -154,7 +154,7 @@ class Redis
...
@@ -154,7 +154,7 @@ class Redis
connect_to_server
if
!
@sock
connect_to_server
if
!
@sock
begin
begin
raw_call_command
(
argv
.
dup
)
raw_call_command
(
argv
.
dup
)
rescue
Errno
::
ECONNRESET
rescue
Errno
::
ECONNRESET
,
Errno
::
EPIPE
@sock
.
close
@sock
.
close
connect_to_server
connect_to_server
raw_call_command
(
argv
.
dup
)
raw_call_command
(
argv
.
dup
)
...
...
redis.c
View file @
c9a111ac
...
@@ -975,15 +975,20 @@ static int yesnotoi(char *s) {
...
@@ -975,15 +975,20 @@ static int yesnotoi(char *s) {
/* I agree, this is a very rudimental way to load a configuration...
/* I agree, this is a very rudimental way to load a configuration...
will improve later if the config gets more complex */
will improve later if the config gets more complex */
static void loadServerConfig(char *filename) {
static void loadServerConfig(char *filename) {
FILE
*
fp
=
fopen
(
filename
,
"r"
)
;
FILE *fp;
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;
if
(
!
fp
)
{
if (filename[0] == '-' && filename[1] == '\0')
redisLog
(
REDIS_WARNING
,
"Fatal error, can't open config file"
);
fp = stdin;
exit
(
1
);
else {
if ((fp = fopen(filename,"r")) == NULL) {
redisLog(REDIS_WARNING,"Fatal error, can't open config file");
exit(1);
}
}
}
while(fgets(buf,REDIS_CONFIGLINE_MAX+1,fp) != NULL) {
while(fgets(buf,REDIS_CONFIGLINE_MAX+1,fp) != NULL) {
sds *argv;
sds *argv;
int argc, j;
int argc, j;
...
@@ -1037,7 +1042,7 @@ static void loadServerConfig(char *filename) {
...
@@ -1037,7 +1042,7 @@ static void loadServerConfig(char *filename) {
goto loaderr;
goto loaderr;
}
}
} else if (!strcasecmp(argv[0],"logfile") && argc == 2) {
} else if (!strcasecmp(argv[0],"logfile") && argc == 2) {
FILE
*
fp
;
FILE *
log
fp;
server.logfile = zstrdup(argv[1]);
server.logfile = zstrdup(argv[1]);
if (!strcasecmp(server.logfile,"stdout")) {
if (!strcasecmp(server.logfile,"stdout")) {
...
@@ -1047,13 +1052,13 @@ static void loadServerConfig(char *filename) {
...
@@ -1047,13 +1052,13 @@ static void loadServerConfig(char *filename) {
if (server.logfile) {
if (server.logfile) {
/* Test if we are able to open the file. The server will not
/* Test if we are able to open the file. The server will not
* be able to abort just for this problem later... */
* be able to abort just for this problem later... */
fp
=
fopen
(
server
.
logfile
,
"a"
);
log
fp = fopen(server.logfile,"a");
if
(
fp
==
NULL
)
{
if (
log
fp == NULL) {
err = sdscatprintf(sdsempty(),
err = sdscatprintf(sdsempty(),
"Can't open the log file: %s", strerror(errno));
"Can't open the log file: %s", strerror(errno));
goto loaderr;
goto loaderr;
}
}
fclose
(
fp
);
fclose(
log
fp);
}
}
} else if (!strcasecmp(argv[0],"databases") && argc == 2) {
} else if (!strcasecmp(argv[0],"databases") && argc == 2) {
server.dbnum = atoi(argv[1]);
server.dbnum = atoi(argv[1]);
...
@@ -1099,7 +1104,7 @@ static void loadServerConfig(char *filename) {
...
@@ -1099,7 +1104,7 @@ static void loadServerConfig(char *filename) {
zfree(argv);
zfree(argv);
sdsfree(line);
sdsfree(line);
}
}
fclose
(
fp
);
if (fp != stdin)
fclose(fp);
return;
return;
loaderr:
loaderr:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment