-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmp_main.c
33 lines (26 loc) · 847 Bytes
/
mp_main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
* Description:
* History: yang@haipo.me, 2017/04/16, create
*/
#include "ut_redis.h"
const char *__process__ = "marketprice";
const char *__version__ = "0.1.0";
int main(int argc, char *argv[])
{
printf("process: %s version: %s, compile date: %s %s\n", __process__, __version__, __DATE__, __TIME__);
struct timeval timeout = { 3, 0 };
redisContext *redis = redisConnectWithTimeout("127.0.0.1", 26379, timeout);
if (redis == NULL || redis->err) {
if (redis) {
redisFree(redis);
}
}
redisReply *reply = redisCommand(redis, "SENTINEL get-master-addr-by-name %s", "mymaster");
if (reply == NULL || reply->type != REDIS_REPLY_ARRAY || reply->elements != 2) {
if (reply) {
freeReplyObject(reply);
redisFree(redis);
}
}
return 0;
}