int main(int argc, char **argv) {
struct timeval tv;
/* We need to initialize our libraries, and the server configuration. */
#ifdef INIT_SETPROCTITLE_REPLACEMENT
spt_init(argc, argv);
#endif
setlocale(LC_COLLATE,"");
/* 设置线程安全标志 */
zmalloc_enable_thread_safeness();
/* 设置内存管理函数 */
zmalloc_set_oom_handler(redisOutOfMemoryHandler);
/* 设置随机数种子 */
srand(time(NULL)^getpid());
/* 得到当前时间,下面设置哈希函数种子时会用到 */
gettimeofday(&tv,NULL);
/* 设置哈希函数种子 */
dictSetHashFunctionSeed(tv.tv_sec^tv.tv_usec^getpid());
/* 检查是否开启哨兵 */
server.sentinel_mode = checkForSentinelMode(argc,argv);
/* 初始化server变量 */
initServerConfig();
/* We need to init sentinel right now as parsing the configuration file
* in sentinel mode will have the effect of populating the sentinel
* data structures with master nodes to monitor. */
if (server.sentinel_mode) {
/* 设置哨兵相关配置,目前只有一个port选项,默认值为263
redis源码分析----main函数
最新推荐文章于 2024-01-06 14:50:23 发布
本文深入分析Redis的源码,主要聚焦在`main`函数中,包括初始化过程、配置文件处理、哨兵模式的检测及启动、内存管理、哨兵系统的初始化、守护进程设置以及数据加载等关键步骤。
摘要由CSDN通过智能技术生成