Redis Boot Process

Source: Internet
Author: User

Tags: NTS conf max block message void startup process Char ESS

I. Entrance
int main (int argc, char **argv)

Two. Main () Processing
1. Server Configuration Initialization
Various configuration initialization
void Initserverconfig (void)
The Redis command is initialized, and Server.commands is initialized here.
Populatecommandtable (void)

2. Loading the configuration
Loading the configuration file
void Loadserverconfig (char *filename, char *options)
Load the compounding string generated by the method above
Loadserverconfigfromstring (char *config)

3. Server initialization
void Initserver (void)
Notification message static data initialization
Createsharedobjects ()
Maximum Open File Settings
Adjustopenfileslimit ()
Event Listener
Server.el = Aecreateeventloop (SERVER.MAXCLIENTS+CONFIG_FDSET_INCR);
DB Memory Initialization
server.db = Zmalloc (sizeof (REDISDB) *server.dbnum);
TCP Listener Port initialization
Listentoport (Server.port,server.ipfd,&server.ipfd_count)
SERVER.SOFD = Anetunixserver (server.neterr,server. Server.unixsocketperm, Server.tcp_backlog)
DB initialization:

/ *Create the Redis databases, and initialize other internal state.*/     for(j =0; J < Server.dbnum; J + +) {server.db[j].dict= Dictcreate (&dbdicttype,null); Server.db[j].expires= Dictcreate (&keyptrdicttype,null); Server.db[j].blocking_keys= Dictcreate (&keylistdicttype,null); Server.db[j].ready_keys= Dictcreate (&setdicttype,null); Server.db[j].watched_keys= Dictcreate (&keylistdicttype,null); Server.db[j].eviction_pool=Evictionpoolalloc (); Server.db[j].id=J; Server.db[j].avg_ttl=0; }

    
Scheduled Tasks and Listener event initialization:

/ *Create the Servercron () time event, that's our main from process * background operations.*/    if(Aecreatetimeevent (Server.el,1, Servercron, NULL, null) = =Ae_err) {Serverpanic ("Can ' t create the Servercron time event."); Exit (1); }    /*Create an event handler for accepting new connections in TCP and Unix * domain sockets.*/     for(j =0; J < Server.ipfd_count; J + +) {        if(Aecreatefileevent (Server.el, Server.ipfd[j], ae_readable, Accepttcphandler,null)==Ae_err) {Serverpanic ("unrecoverable Error creating SERVER.IPFD file event."); }    }    if(Server.sofd >0&&aecreatefileevent (server.el,server.sofd,ae_readable, Acceptunixhandler,null)= = Ae_err) serverpanic ("unrecoverable Error creating SERVER.SOFD file event.");

4. Loading data
Loaddatafromdisk ()


5. Server Open
Aesetbeforesleepproc (Server.el,beforesleep);
Network Event Listener Boot
Aemain (Server.el);
Aedeleteeventloop (Server.el);

Redis Boot Process

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: