int maxidletime;
int dbnum;
int daemonize;
+ char *pidfile;
int bgsaveinprogress;
struct saveparam *saveparams;
int saveparamslen;
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 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 {
/* Create a list of operations to perform for every sorted element.
* Operations can be GET/DEL/INCR/DECR */
operations = listCreate();
- listSetFreeMethod(operations,free);
+ listSetFreeMethod(operations,zfree);
j = 2;
/* Now we need to protect sortval incrementing its count, in the future
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;