run_id added to INFO output.

The Run ID is a field that identifies a single execution of the Redis
server. It can be useful for many purposes as it makes easy to detect if
the instance we are talking about is the same, or if it is a different
one or was rebooted. An application of run_id will be in the partial
synchronization of replication, where a slave may request a partial sync
from a given offset only if it is talking with the same master. Another
application is in failover and monitoring scripts.
This commit is contained in:
antirez 2012-03-08 10:13:12 +01:00
parent 44f508f1a8
commit 91d664d6ce
2 changed files with 5 additions and 0 deletions

View File

@ -870,6 +870,8 @@ void createSharedObjects(void) {
}
void initServerConfig() {
getRandomHexChars(server.runid,REDIS_RUN_ID_SIZE);
server.runid[REDIS_RUN_ID_SIZE] = '\0';
server.arch_bits = (sizeof(long) == 8) ? 64 : 32;
server.port = REDIS_SERVERPORT;
server.bindaddr = NULL;
@ -1585,6 +1587,7 @@ sds genRedisInfoString(char *section) {
"multiplexing_api:%s\r\n"
"gcc_version:%d.%d.%d\r\n"
"process_id:%ld\r\n"
"run_id:%s\r\n"
"tcp_port:%d\r\n"
"uptime_in_seconds:%ld\r\n"
"uptime_in_days:%ld\r\n"
@ -1600,6 +1603,7 @@ sds genRedisInfoString(char *section) {
0,0,0,
#endif
(long) getpid(),
server.runid,
server.port,
uptime,
uptime/(3600*24),

View File

@ -570,6 +570,7 @@ struct redisServer {
char *pidfile; /* PID file path */
int arch_bits; /* 32 or 64 depending on sizeof(long) */
int cronloops; /* Number of times the cron function run */
char runid[REDIS_RUN_ID_SIZE+1]; /* ID always different at every exec. */
/* Networking */
int port; /* TCP listening port */
char *bindaddr; /* Bind address or NULL */