1. Prepare to run the environment
* Set Oom Handler,zmalloc allocated memory failed to call
* Initialize random seeds to generate random numbers
* Initialize server parameters to default values
* Create a mapping table for commands and processing functions
2. Parse the command-line arguments, Loadserverconfig () resolve the configuration file
* The configuration file overwrites the parameters specified by the command line
* Invalid configuration item or unreasonable configuration value will cause Redis to not start properly
3. Initserver () initialization service
* Install signal processing function
* Create shared objects, Redis commonly used objects for sharing to save memory
* Adjust Max open files according to MAXC lients configuration
* Create a global DB dictionary, each db corresponds to a dict
* Monitor network ports, install event handlers
* If AoF is turned on, open aof file
* Create Servercron Timer
4. Loaddatafromdisk () loading data from RDB or aof files
* Load data error (such as file format confusion) and so on will cause Redis can not start normally
* In the process of loading, Redis can still process the request, but most requests will reply-loading error
5. Aemain () Start event loop, receive client request
The event handler function that listens for the file descriptor is initialized to Accepttcphandler, and the newly established connection's event handler function is set to readqueryfromclient,readqueryfromclient read requests from the network connection. Resolves the request parameters and processes them.