* POSSIBILITY OF SUCH DAMAGE.
*/
-#define REDIS_VERSION "1.3.6"
+#define REDIS_VERSION "1.3.7"
#include "fmacros.h"
#include "config.h"
{NULL,NULL,0,0,NULL,0,0,0}
};
+static void usage();
+
/*============================ Utility functions ============================ */
/* Glob-style pattern matching. */
dictListDestructor /* val destructor */
};
+static void version();
+
/* ========================= Random utility functions ======================= */
/* Redis generally does not try to recover from out of memory conditions
char buf[REDIS_CONFIGLINE_MAX+1], *err = NULL;
int linenum = 0;
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')
fp = stdin;
else {
if ((fp = fopen(filename,"r")) == NULL) {
- redisLog(REDIS_WARNING,"Fatal error, can't open config file");
+ redisLog(REDIS_WARNING, errorbuf);
exit(1);
}
}
if (server.dbnum < 1) {
err = "Invalid number of databases"; goto loaderr;
}
+ } else if (!strcasecmp(argv[0],"include") && argc == 2) {
+ loadServerConfig(argv[1]);
} else if (!strcasecmp(argv[0],"maxclients") && argc == 2) {
server.maxclients = atoi(argv[1]);
} else if (!strcasecmp(argv[0],"maxmemory") && argc == 2) {
int j;
char hmem[64];
- server.hash_max_zipmap_entries = REDIS_HASH_MAX_ZIPMAP_ENTRIES;
- server.hash_max_zipmap_value = REDIS_HASH_MAX_ZIPMAP_VALUE;
-
bytesToHuman(hmem,zmalloc_used_memory());
info = sdscatprintf(sdsempty(),
"redis_version:%s\r\n"
}
}
+static void version() {
+ printf("Redis server version %s\n", REDIS_VERSION);
+ exit(0);
+}
+
+static void usage() {
+ fprintf(stderr,"Usage: ./redis-server [/path/to/redis.conf]\n");
+ exit(1);
+}
+
int main(int argc, char **argv) {
time_t start;
initServerConfig();
if (argc == 2) {
+ if (strcmp(argv[1], "-v") == 0 ||
+ strcmp(argv[1], "--version") == 0) version();
+ if (strcmp(argv[1], "--help") == 0) usage();
resetServerSaveParams();
loadServerConfig(argv[1]);
- } else if (argc > 2) {
- fprintf(stderr,"Usage: ./redis-server [/path/to/redis.conf]\n");
- exit(1);
+ } else if ((argc > 2)) {
+ usage();
} 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'");
}