int maxidletime;
int dbnum;
int daemonize;
+ char *pidfile;
int bgsaveinprogress;
struct saveparam *saveparams;
int saveparamslen;
static void sortCommand(redisClient *c);
static void lremCommand(redisClient *c);
static void infoCommand(redisClient *c);
+static void mgetCommand(redisClient *c);
/*================================= Globals ================================= */
{"exists",existsCommand,2,REDIS_CMD_INLINE},
{"incr",incrCommand,2,REDIS_CMD_INLINE},
{"decr",decrCommand,2,REDIS_CMD_INLINE},
+ {"mget",mgetCommand,-2,REDIS_CMD_INLINE},
{"rpush",rpushCommand,3,REDIS_CMD_BULK},
{"lpush",lpushCommand,3,REDIS_CMD_BULK},
{"rpop",rpopCommand,2,REDIS_CMD_INLINE},
server.bindaddr = NULL;
server.glueoutputbuf = 1;
server.daemonize = 0;
+ server.pidfile = "/var/run/redis.pid";
server.dbfilename = "dump.rdb";
ResetServerSaveParams();
else {
err = "argument must be 'yes' or 'no'"; goto loaderr;
}
+ } else if (!strcmp(argv[0],"pidfile") && argc == 2) {
+ server.pidfile = zstrdup(argv[1]);
} else {
err = "Bad directive or wrong number of arguments"; goto loaderr;
}
}
}
+static void mgetCommand(redisClient *c) {
+ dictEntry *de;
+ int j;
+
+ addReplySds(c,sdscatprintf(sdsempty(),"%d\r\n",c->argc-1));
+ for (j = 1; j < c->argc; j++) {
+ de = dictFind(c->dict,c->argv[j]);
+ if (de == NULL) {
+ addReply(c,shared.minus1);
+ } else {
+ robj *o = dictGetEntryVal(de);
+
+ if (o->type != REDIS_STRING) {
+ addReply(c,shared.minus1);
+ } else {
+ addReplySds(c,sdscatprintf(sdsempty(),"%d\r\n",(int)sdslen(o->ptr)));
+ addReply(c,o);
+ addReply(c,shared.crlf);
+ }
+ }
+ }
+}
+
static void incrDecrCommand(redisClient *c, int incr) {
dictEntry *de;
long long value;
static void shutdownCommand(redisClient *c) {
redisLog(REDIS_WARNING,"User requested shutdown, saving DB...");
if (saveDb(server.dbfilename) == REDIS_OK) {
+ if (server.daemonize) {
+ unlink(server.pidfile);
+ }
redisLog(REDIS_WARNING,"Server exit now, bye bye...");
exit(1);
} else {
);
addReplySds(c,sdscatprintf(sdsempty(),"%d\r\n",sdslen(info)));
addReplySds(c,info);
+ addReply(c,shared.crlf);
}
/* =============================== Replication ============================= */
if (fd > STDERR_FILENO) close(fd);
}
/* Try to write the pid file */
- fp = fopen("/var/run/redis.pid","w");
+ fp = fopen(server.pidfile,"w");
if (fp) {
fprintf(fp,"%d\n",getpid());
fclose(fp);
redisLog(REDIS_NOTICE,"DB loaded from disk");
if (aeCreateFileEvent(server.el, server.fd, AE_READABLE,
acceptHandler, NULL, NULL) == AE_ERR) oom("creating file event");
- redisLog(REDIS_NOTICE,"The server is now ready to accept connections");
+ redisLog(REDIS_NOTICE,"The server is now ready to accept connections on port %d", server.port);
aeMain(server.el);
aeDeleteEventLoop(server.el);
return 0;