diff --git a/README.Garantia b/README.Garantia index f48e14be7..e97be5ad7 100644 --- a/README.Garantia +++ b/README.Garantia @@ -37,6 +37,16 @@ background save operation to a specific file. This operation also doesn't modify the fields above. +Additional Redis Configuration Parameters +----------------------------------------- + +load-on-startup + Provides the ability to disable auto-loading of RDB/AOF files on startup, + even if they exist. This is useful on slaves that would immediately need + to replicate from masters anyway. + + + New/Modified Redis Commands --------------------------- diff --git a/redis.conf b/redis.conf index adaa24c20..3425b9d9e 100755 --- a/redis.conf +++ b/redis.conf @@ -130,6 +130,9 @@ dbfilename dump.rdb # specified, this is the same as dbfilename. syncdbfilename sync.rdb +# Determine if redis should load rdb or aof when available on startup +load-on-startup yes + # The working directory. # # The DB will be written inside this directory, with the filename specified diff --git a/src/config.c b/src/config.c index fa2296112..79216fee7 100755 --- a/src/config.c +++ b/src/config.c @@ -256,6 +256,10 @@ void loadServerConfigFromString(char *config) { if ((server.daemonize = yesnotoi(argv[1])) == -1) { err = "argument must be 'yes' or 'no'"; goto loaderr; } + } else if (!strcasecmp(argv[0],"load-on-startup") && argc == 2) { + if ((server.load_on_startup = yesnotoi(argv[1])) == -1) { + err = "argument must be 'yes' or 'no'"; goto loaderr; + } } else if (!strcasecmp(argv[0],"conditional-sync") && argc == 2) { if ((server.conditional_sync = yesnotoi(argv[1])) == -1) { err = "argument must be 'yes' or 'no'"; goto loaderr; diff --git a/src/redis.c b/src/redis.c index 7734c7465..4bd356aa4 100755 --- a/src/redis.c +++ b/src/redis.c @@ -1102,6 +1102,7 @@ void initServerConfig() { server.syslog_ident = zstrdup("redis"); server.syslog_facility = LOG_LOCAL0; server.daemonize = 0; + server.load_on_startup = 1; server.conditional_sync = 1; server.aof_state = REDIS_AOF_OFF; server.aof_fsync = AOF_FSYNC_EVERYSEC; @@ -2636,7 +2637,8 @@ int main(int argc, char **argv) { #ifdef __linux__ linuxOvercommitMemoryWarning(); #endif - loadDataFromDisk(); + if (server.load_on_startup) + loadDataFromDisk(); if (server.ipfd > 0) redisLog(REDIS_NOTICE,"The server is now ready to accept connections on port %d", server.port); if (server.sofd > 0) diff --git a/src/redis.h b/src/redis.h index 422b5fe91..3cbc9f65e 100755 --- a/src/redis.h +++ b/src/redis.h @@ -568,6 +568,7 @@ struct redisServer { size_t client_max_querybuf_len; /* Limit for client query buffer length */ int dbnum; /* Total number of configured DBs */ int daemonize; /* True if running as a daemon */ + int load_on_startup; /* True if server should load AOF/RDB on startup */ int conditional_sync; /* Conditional synchronziation support */ clientBufferLimitsConfig client_obuf_limits[REDIS_CLIENT_LIMIT_NUM_CLASSES]; /* AOF persistence */