From d95592b11689130382d7bf71aedf8963cc7f7431 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 13 May 2013 11:26:43 +0200 Subject: CONFIG REWRITE: support for dir and slaveof. --- src/config.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/config.c b/src/config.c index 340e93d46..52c4dca1f 100644 --- a/src/config.c +++ b/src/config.c @@ -1329,9 +1329,21 @@ void rewriteConfigSaveOption(struct rewriteConfigState *state) { } void rewriteConfigDirOption(struct rewriteConfigState *state) { + char cwd[1024]; + + if (getcwd(cwd,sizeof(cwd)) == NULL) return; /* no rewrite on error. */ + rewriteConfigStringOption(state,"dir",cwd,NULL); } void rewriteConfigSlaveofOption(struct rewriteConfigState *state) { + sds line; + + /* If this is a master, we want all the slaveof config options + * in the file to be removed. */ + if (server.masterhost == NULL) return; + line = sdscatprintf(sdsempty(),"slaveof %s %d", + server.masterhost, server.masterport); + rewriteConfigRewriteLine(state,"slaveof",line,1); } void rewriteConfigAppendonlyOption(struct rewriteConfigState *state) { -- cgit v1.2.1