A configuration conversion method, device, equipment and storage medium

By automatically converting the conf configuration of Nginx application to json configuration, the resource occupation problems caused by frequent reload and the inefficiency of manual translation are solved, efficient and accurate configuration conversion is achieved, and business service quality is improved.

CN119766862APending Publication Date: 2025-04-04CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411782572.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-05
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

In Nginx applications in CDN systems, frequent execution of reload instructions will cause the old worker process to be recycled for a long time, which will lead to excessive memory resource usage, seriously affecting the business. At the same time, the existing json hot loading system requires manual translation of the conf configuration file into a json configuration, which is inefficient.

Method used

Provides a configuration conversion method, by obtaining the conf configuration of Nginx application, generate a conf instruction analysis tree, and automatically convert it to the target json configuration based on the tree and target instruction conversion rules, avoiding manual translation errors and improving efficiency.

Benefits of technology

This method reduces the error rate of manual translation, improves the accuracy and efficiency of configuration conversion, reduces Nginx memory resource usage, reduces maintenance costs, and improves business service quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119766862A_ABST
    Figure CN119766862A_ABST
Patent Text Reader

Abstract

The present application provides a configuration conversion method, device, equipment and storage medium, which belongs to the technical field of data processing. The method includes: obtaining the conf configuration of the Nginx application of the CDN system; generating a corresponding conf instruction analysis tree according to the conf configuration, and the conf instruction analysis tree is used to characterize the hierarchical nesting relationship between instruction blocks in the conf configuration; generating a target json configuration corresponding to the conf configuration according to the conf instruction analysis tree and the target instruction conversion rule, and the target instruction conversion rule is the conversion rule from the instruction in the conf configuration to the json configuration. The present application aims to improve the efficiency of the configuration conversion process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to the technical field of data processing, and in particular, to a configuration conversion method, apparatus, device, and storage medium. Background Art

[0002] At present, Nginx is a widely used high-performance http and reverse proxy web server, and an important part of the CDN (Content Delivery Network) system; the business logic of the Nginx program needs to be configured in the conf configuration file.

[0003] In the current Nginx application of the CDN system, when business requirements change, the conf configuration needs to be modified, and then the Nginx process needs to be reloaded and restarted to take effect; when Nginx executes the reload command, a new Nginx process needs to be started again, and the gateway reinitializes the configuration after reloading the configuration, and the updated configuration can take effect; when Nginx executes the reload command, the old worker process will actively disconnect after processing the existing connection, resulting in a particularly long recycling time for the old worker process. If the reload command is executed frequently, the number of shutting down processes will continue to increase, and eventually even excessive usage of Nginx memory and other resources will occur, seriously affecting the business.

[0004] Currently, there is a json hot loading system applied to Nginx. Compared with the process of modifying the conf configuration file and then performing the reload operation, the json hot loading system can load the configuration in real time without performing the reload operation, that is, real-time hot update and loading the latest domain name configuration. The usual method is to manually translate the conf configuration file into a json configuration that can be applied to the json hot loading system. However, the process of manually changing the format is not only prone to errors, but also time-consuming and labor-intensive, resulting in inefficient configuration conversion process. Summary of the invention

[0005] The embodiments of the present application provide a configuration conversion method, apparatus, device and storage medium, aiming to improve the efficiency of the configuration conversion process.

[0006] In a first aspect, an embodiment of the present application provides a configuration conversion method, which is applied to a CDN system, and the method includes: Get the conf configuration of the Nginx application of the CDN system; Generate a corresponding conf instruction analysis tree according to the conf configuration, wherein the conf instruction analysis tree is used to represent the hierarchical nesting relationship between instruction blocks in the conf configuration; According to the conf instruction analysis tree and the target instruction conversion rule, a target json configuration corresponding to the conf configuration is generated, and the target instruction conversion rule is a conversion rule from instructions in the conf configuration to json configuration.

[0007] Optionally, generating a corresponding conf instruction analysis tree according to the conf configuration includes: Performing lexical analysis on the conf configuration, determining any identifier in the conf configuration, and sequentially composing all identifiers in the conf configuration into an identifier sequence; Perform grammatical analysis on the identification sequence of the conf configuration, determine any instruction of the conf configuration and the nested relationship between instructions, and generate a conf instruction analysis tree corresponding to the conf configuration, wherein the leaf nodes in the conf instruction analysis tree are instruction blocks corresponding to any business logic, and the instruction block includes at least one instruction.

[0008] Optionally, generating a target json configuration corresponding to the conf configuration according to the conf instruction analysis tree and the target instruction conversion rule includes: Traverse any instruction block in the conf instruction analysis tree, and convert the instruction block into a corresponding json configured instruction block according to the target instruction conversion rule; According to the hierarchical nesting relationship between the instruction blocks of the conf instruction analysis tree, the instruction blocks of each json configuration obtained by conversion are collected and combined to obtain the target json configuration corresponding to the conf configuration.

[0009] Optionally, traversing any instruction block in the conf instruction analysis tree, and converting the instruction block into a corresponding json-configured instruction block according to the target instruction conversion rule, includes: Traverse any instruction block in the conf instruction analysis tree; When the instruction block includes a single instruction, generating a json-configured instruction corresponding to the single instruction as a json-configured instruction block according to the target instruction conversion rule; When the instruction block is an if instruction block, according to the target instruction conversion rule, any instruction in the if instruction block is converted into an instruction of the json configuration corresponding to the instruction, and according to the configuration information of the if instruction block, the instructions of the json configuration corresponding to any instruction in the if instruction block are combined into an instruction block of the json configuration corresponding to the if instruction block, wherein the configuration information of the if instruction block includes the if condition and various configurations in the if instruction block; When the instruction block is a location instruction block, according to the target instruction conversion rule, any instruction in the location instruction block is converted into an instruction configured in json corresponding to the instruction, and according to the configuration information of the location instruction block, the instructions configured in json corresponding to any instruction in the location instruction block are combined into an instruction block configured in json corresponding to the location instruction block, wherein the configuration information of the location instruction block includes url routing rules.

[0010] Optionally, traversing any instruction block in the conf instruction analysis tree, and converting the instruction block into a corresponding json-configured instruction block according to the target instruction conversion rule, includes: The process of traversing any instruction block in the conf instruction analysis tree; For any set response header instruction, generate the json configuration instruction corresponding to the set response header instruction according to the target instruction conversion rule, and add the json configuration instruction corresponding to the set response header instruction to the response header list, which is located at the target position of the target json configuration.

[0011] Optionally, according to the hierarchical nesting relationship between instruction blocks of the conf instruction analysis tree, the instruction blocks of each json configuration obtained by conversion are collected and combined to obtain a target json configuration corresponding to the conf configuration, including: Record any global information in the conf configuration, the global information including the business domain name configuration global status information; According to the hierarchical nesting relationship between the instruction blocks of the conf instruction analysis tree and any global information, the instruction blocks of each json configuration obtained by conversion are collected and combined to obtain the target json configuration corresponding to the conf configuration.

[0012] Optionally, after generating the target json configuration corresponding to the conf configuration, the method further includes: Send the target json configuration to the json hot loading system of the CDN system; When responding to any configuration modification operation, the configuration to be modified is obtained, and the configuration to be modified in the target json configuration is modified.

[0013] In a second aspect, an embodiment of the present application provides a configuration conversion device, which is applied to a CDN system, and the device includes: An acquisition module is used to obtain the conf configuration of the Nginx application of the CDN system; A first generating module, used to generate a corresponding conf instruction analysis tree according to the conf configuration, wherein the conf instruction analysis tree is used to represent the hierarchical nesting relationship between instruction blocks in the conf configuration; The second generation module is used to generate a target json configuration corresponding to the conf configuration according to the conf instruction analysis tree and the target instruction conversion rule, and the target instruction conversion rule is a conversion rule from instructions in the conf configuration to json configuration.

[0014] In a third aspect, an embodiment of the present application provides a computer device, comprising: at least one processor, and a memory, wherein the memory stores a computer program that can be run on the processor, wherein when the processor executes the computer program, the configuration conversion method described in the first aspect of the embodiment is performed.

[0015] In a fourth aspect, an embodiment of the present application provides a non-volatile readable storage medium, wherein the non-volatile readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the configuration conversion method described in the first aspect of the embodiment is performed.

[0016] Beneficial effects: Obtain the conf configuration of the Nginx application of the CDN system; generate a corresponding conf instruction analysis tree according to the conf configuration, wherein the conf instruction analysis tree is used to characterize the hierarchical nesting relationship between instruction blocks in the conf configuration; generate a target json configuration corresponding to the conf configuration according to the conf instruction analysis tree and a target instruction conversion rule, wherein the target instruction conversion rule is a conversion rule from instructions in the conf configuration to json configuration.

[0017] In this configuration conversion method, the conf instruction analysis tree of the conf configuration is obtained according to the conf configuration, and then the conf configuration is automatically converted into the target json configuration corresponding to the conf configuration. Compared with manually translating the conf configuration file into the json configuration, it can not only avoid more errors in the translation process and improve the accuracy of the conversion, but also improve the efficiency of the configuration conversion process. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0019] Figure 1 is a flowchart of the steps of the configuration conversion method proposed in one embodiment of the present application; Figure 2 is a schematic diagram of executing the configuration conversion method proposed in one embodiment of the present application; Figure 3 is a schematic diagram of executing a configuration conversion method provided in an embodiment of the present application; Figure 4 is an execution flow chart of a configuration conversion method proposed in an embodiment of the present application; Figure 5 It is a functional module diagram of a configuration conversion device proposed in one embodiment of the present application; Figure 6 is a schematic diagram of a computer device provided by an embodiment of the present application; Figure 7 It is a schematic diagram of a non-volatile readable storage medium proposed in an embodiment of the present application. DETAILED DESCRIPTION

[0020] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0021] CDN: Content Delivery Network is an intelligent virtual network between the client and the server. It redirects the client request to the cache server that is closest to the user and in the best condition based on comprehensive information such as different request content, network traffic, connection and load status of each node, distance to the user and response time, so that the user can obtain the required content nearby. The CDN system uses its cache of historical traffic to enable users to obtain the required content nearby, thereby effectively alleviating the access delay problem caused by distance distribution, bandwidth and server performance, and alleviating the backbone network traffic congestion caused by a large number of remote accesses; CDN acts as a proxy for network flows between the client and the server, generally at the http level, and takes over the domain name access.

[0022] Nginx is a high-performance HTTP and reverse proxy web server application, which is characterized by small memory usage and strong concurrency. As a reverse proxy server, Nginx means that it proxies clients to send requests to other servers. The client does not communicate directly with the target server, but through Nginx. It is an important part of the current CDN service; Nginx can be used for reverse proxy, load balancing, caching, current limiting, black / white list, static resource service, dynamic and static separation, anti-hotlinking, cross-domain and high availability. Due to its powerful capabilities, it is widely used in Internet projects, especially in the construction of CDN; the business logic of the Nginx service needs to be described in the conf configuration file. If the conf configuration is changed, the reload operation must be executed on Nginx to restart; when Nginx executes the reload instruction, it does not need to stop Nginx or interrupt the request. It immediately pulls up a new worker process to undertake new client requests, and the old worker process needs to process the existing connections before it can exit.

[0023] The conf configuration file is a configuration file used in Nginx to describe the business processes it carries. It can carry the business logic of a large number of business domain names. Different businesses are configured in instructions or instruction blocks according to the hierarchical relationship. It consists of three parts (or levels), namely the global block, the events block, and the http block. The global block is used to configure instructions that affect Nginx globally, such as the running path and the number of worker processes; the events block is used to configure the event-driven model used by Nginx; the http block can nest multiple server blocks to configure proxy, cache, log format definition and other functions. The server block is the business domain name and its service carried by Nginx. The embodiment of the richness of HTTP, there are multiple servers in an http block, each server block can describe the specific business configuration of one or more domain names, and configure the relevant parameters of the virtual host such as domain name port, etc.; in addition, different location blocks can be configured in the server block to implement different URL routing rules. Through a series of instructions configured in the server block, reverse proxy, load balancing, caching, current limiting, black / white list, static resource service, dynamic and static separation, anti-hotlinking and cross-domain configuration of client requests can be implemented; among them, the instruction configuration block contains one or more instructions for describing a single business configuration, and multiple instruction configuration blocks are nested to form a complete business logic.

[0024] At present, Nginx is a widely used high-performance http and reverse proxy web server. It is used as a gateway and is an important part of the CDN system. The business logic of the Nginx program needs to be described in its conf configuration file. The relevant parameters of the virtual host it carries are usually described by the server configuration block. A server block configuration usually consists of service information such as domain name and port and multiple location blocks for URL routing rules. It can support reverse proxy, load balancing, caching, current limiting, black / white list, static resource service, dynamic and static separation, anti-hotlinking, cross-domain and high availability through the configuration of a series of Nginx instructions. The large number of business domain name requirements in CDN can be described in a large number of Nginx conf files.

[0025] In the current Nginx application of the CDN system, when business requirements change, the conf configuration needs to be modified, and then the Nginx process needs to be reloaded and restarted to take effect; when Nginx executes the reload command, a new Nginx process needs to be started again, and the gateway reinitializes the configuration after reloading the configuration, and the updated configuration can take effect; when Nginx executes the reload command, the old worker process will actively disconnect after processing the existing connection; even if the worker process receives an exit command from the master, it cannot exit immediately, but needs to wait until these connections are abnormal, time out, or one end actively disconnects before it can exit normally.

[0026] This results in a particularly long recycling time for the old worker process. If the reload command is executed frequently, the number of shut down processes will continue to increase, and eventually even Nginx memory and other resources will be over-occupied, seriously affecting the business.

[0027] Currently, there is a json hot loading system applied to Nginx. Compared with the process of modifying the conf configuration file and then reloading it, the json hot loading system can load the configuration in real time without reloading the Nginx process, that is, real-time hot update and loading the latest domain name configuration. Usually, the conf configuration file is manually translated into a json configuration that can be applied to the json hot loading system. However, the process of manually changing the format is not only prone to errors, but also time-consuming and labor-intensive, resulting in inefficient configuration conversion process.

[0028] Therefore, the embodiment of the present application provides a configuration conversion method, which can automatically convert the conf configuration file into the json configuration format, which not only reduces the problem of error-prone manual translation, but also improves the efficiency of the configuration conversion process, saves complicated and lengthy manual operations, and can accelerate the launch of Nginx's json hot loading system and reduce maintenance costs.

[0029] Reference Figure 1 , shows a flowchart of a configuration conversion method in an embodiment of the present application, the method can be applied to a CDN system, and the method can specifically include the following steps: S101: Obtain the conf configuration of the Nginx application of the CDN system.

[0030] In the actual implementation process, when obtaining the current conf configuration of the Nginx application of the CDN system, the current conf configuration can be pulled at any time when the Nginx application runs normally according to the current conf configuration, and the process of actively converting from the conf configuration to the target json configuration can be selected according to the needs of the actual application.

[0031] It is also possible to actively trigger the configuration conversion process after detecting a change in the conf configuration, so that the Nginx application of the CDN system runs based on the target json configuration obtained by converting the changed conf configuration, thereby avoiding the need to reload the Nginx process after the change; the triggering condition or triggering time of the configuration conversion can be selected according to the needs of the actual application, and this embodiment does not make a selection.

[0032] The conf configuration of the pulled Nginx application uses the domain name as the management granularity, including but not limited to the server block that describes the domain name and other auxiliary instruction blocks. For example, a server block can include basic instructions for describing or configuring the business domain name, and several location blocks and their business instructions for specifying URL routing rules.

[0033] S102: Generate a corresponding conf instruction analysis tree according to the conf configuration, where the conf instruction analysis tree is used to represent the hierarchical nesting relationship between instruction blocks in the conf configuration.

[0034] In a feasible implementation manner, the process of generating a corresponding conf instruction analysis tree according to the conf configuration includes the following steps: A1: Perform lexical analysis on the conf configuration, determine any identifier in the conf configuration, and compose all identifiers in the conf configuration into an identifier sequence in order.

[0035] Specifically, the string in the conf configuration can be lexically analyzed by a lexical analyzer, and lexical units can be segmented and identified as identifiers, that is, tokens can be identified. Tokens can include individual words or keywords, identifiers, constants, and operators in the source code of the conf configuration; then all the identified identifiers, i.e. tokens, are sequentially organized into an identifier sequence.

[0036] A2: Perform grammatical analysis on the identification sequence of the conf configuration, determine any instruction of the conf configuration and the nested relationship between instructions, and generate a conf instruction analysis tree corresponding to the conf configuration, wherein the leaf nodes in the conf instruction analysis tree are instruction blocks corresponding to any business logic, and the instruction block includes at least one instruction.

[0037] After lexical analysis, the identified identification sequence can be subjected to grammatical analysis to identify the meaning of each token. The token sequence is analyzed one by one and converted into a tree data structure, namely, the conf instruction analysis tree. The conf instruction analysis tree is a hierarchical nested relationship of instruction blocks used to describe any business logic in the conf configuration.

[0038] For example, some pseudo code in any http block in the conf configuration is as follows: http { … server { … server_name test.com; … location / { proxy_ pass http: / / backend; … } } } When the above pseudocode is lexically analyzed, tokens such as "server_name" and "test.com" can be analyzed. Then, through syntax analysis, it can be determined that "server_name" is the Nginx instruction name, and "test.com" is the specific content of the setting item of the instruction. In addition, the conf instruction analysis tree corresponding to the above pseudocode can be identified, showing the nested relationship between the instruction blocks therein, such as the http block includes the server block, and the server block includes an instruction block composed of an instruction block for setting the business domain name and a location block pair. The instruction block composed of an instruction block for setting the business domain name and a location block pair can be used as a leaf node in the conf instruction analysis tree.

[0039] S103: Generate a target json configuration corresponding to the conf configuration according to the conf instruction analysis tree and the target instruction conversion rule, wherein the target instruction conversion rule is a conversion rule from instructions in the conf configuration to json configuration.

[0040] In a feasible implementation manner, the process of generating a target json configuration corresponding to the conf configuration according to the conf instruction analysis tree and the target instruction conversion rule includes the following steps: B1: traverse any instruction block in the conf instruction analysis tree, and convert the instruction block into a corresponding json configured instruction block according to the target instruction conversion rule.

[0041] Since Nginx instructions are arranged in the form of blocks, a block may include a single instruction or multiple instructions that jointly complete a complex business description or implement the same business logic. In this embodiment, the conf instruction analysis tree is traversed to convert the instructions therein into the target json format. The traversed instruction blocks are converted according to the target instruction conversion rules. The target instruction conversion rules are the conversion rules from the instructions in the conf configuration to the json configuration. The target instruction conversion rules are related to the design rules of the json hot loading system. For example, the target instruction conversion rules are preset according to the json configuration supported by the json hot loading system of the CDN system. The target instruction conversion rules include the process of converting different instructions into instructions of the json configuration.

[0042] Specifically, in the process of traversing any instruction block in the conf instruction analysis tree, when the instruction block includes a single instruction, the json-configured instruction corresponding to the single instruction is generated as the json-configured instruction block according to the target instruction conversion rule.

[0043] In addition, it is also necessary to perform corresponding collection and aggregation according to Nginx rules based on different instruction blocks. For example, when the instruction block is an if instruction block, according to the target instruction conversion rule, any instruction in the if instruction block is converted into an instruction configured with json corresponding to the instruction, and according to the configuration information of the if instruction block, the instructions configured with json corresponding to any instruction in the if instruction block are combined into an instruction block configured with json corresponding to the if instruction block, wherein the configuration information of the if instruction block includes the if conditions and various configurations in the if instruction block.

[0044] That is, for the if instruction block, in addition to converting each instruction in the if instruction block, it is also necessary to collect the if conditions and various configurations in the if instruction block, so as to compose the json-configured instructions converted one by one in the if instruction block according to the collected configuration information of the if instruction block, thereby obtaining an instruction block of json-configured instructions after the if instruction block is converted.

[0045] When the instruction block is a location instruction block, according to the target instruction conversion rule, any instruction in the location instruction block is converted into an instruction configured in json corresponding to the instruction, and according to the configuration information of the location instruction block, the instructions configured in json corresponding to any instruction in the location instruction block are combined into an instruction block configured in json corresponding to the location instruction block, wherein the configuration information of the location instruction block includes url routing rules.

[0046] The location instruction block includes the configuration of url routing rules. A location instruction block may include multiple instructions corresponding to implementing various business function configurations such as anti-hotlink authentication, reverse proxy, and cache. In addition to converting any instruction in the location instruction block according to the target instruction conversion rule, it is also necessary to collect the configuration information of the location instruction block including the url routing rules containing various business function configurations, so as to combine the multiple json-configured instructions obtained by conversion according to the configuration information of the location instruction block to obtain the json-configured instruction block corresponding to the location instruction block. The json-configured instruction block still includes various business function configurations such as anti-hotlink authentication, reverse proxy, and cache.

[0047] Based on the rules of the json hot loading system, multiple setting response header instructions "more_set_header" may be packaged and merged into the same group to form an instruction set for easy execution. Therefore, when traversing the conf instruction analysis tree, it is also necessary to record the setting response header instructions "more_set_header" in different levels such as server{} blocks and location{} blocks, and then organize and merge them into a response header list and place it in the target location of the target json configuration, so that it can be called and executed by Nginx's json hot loading system.

[0048] Therefore, in the process of traversing any instruction block in the conf instruction analysis tree, it may be necessary to collect and summarize the global information inside and outside the comprehensive instruction block level by level. For any set response header instruction, the json configuration instruction corresponding to the set response header instruction is generated according to the target instruction conversion rule, and the json configuration instruction corresponding to the set response header instruction is added to the response header list. The response header list is located at the target position of the target json configuration, and the target position is related to the json configuration.

[0049] B2: According to the hierarchical nesting relationship between the instruction blocks of the conf instruction analysis tree, the instruction blocks of each json configuration obtained by conversion are collected and combined to obtain the target json configuration corresponding to the conf configuration.

[0050] After converting any instruction block one by one, it is necessary to combine each instruction block according to the hierarchical nesting relationship. Therefore, in the process of converting any instruction block, it is also necessary to record any global information in the conf configuration. For example, if there are different levels, different priorities in the conf configuration, or multiple instructions are used to complete any business logic, it is necessary to collect all the information in a unified manner after the traversal is completed to complete the final target json configuration.

[0051] The global information includes but is not limited to business domain name configuration global status information. Business domain name configuration global status information is personalized configuration information of any business domain name. This information may be used in other parts of the subsequent conversion process. For example, when performing instruction block merging operations, it is necessary to combine all the collected information for comprehensive processing; therefore, in the actual implementation process, any global information used for instruction block merging can be extracted or collected for temporary storage.

[0052] Next, according to the hierarchical nesting relationship between the instruction blocks of the conf instruction analysis tree and any global information, the instruction blocks of each json configuration obtained by conversion are collected and combined to obtain the target json configuration corresponding to the conf configuration. Finally, the intermediate results or temporarily stored global information generated during the instruction conversion process are cleaned up.

[0053] In a feasible implementation, after generating the target json configuration corresponding to the conf configuration, the target json configuration is sent to the json hot loading system of the CDN system, so that based on the target json configuration, the latest domain name configuration can be hot updated and loaded in real time without reloading the Nginx process; in the subsequent application process, when the user needs to modify the domain name configuration and other operations, in response to any configuration modification operation, the configuration to be modified is obtained, and the configuration to be modified in the target json configuration is modified.

[0054] Reference Figure 2 , showing an execution schematic diagram of a configuration conversion method provided in an embodiment of the present application, first obtaining the conf configuration corresponding to the Nginx application of the CDN system, then performing lexical analysis and syntax analysis on the conf configuration to obtain the conf configuration to generate the corresponding conf instruction analysis tree, and then based on the target instruction conversion rules for converting the instructions in the conf configuration to the instructions in the json configuration, traversing the conf instruction analysis tree, performing line-by-line conversion of the instructions and collecting and summarizing the global information level by level, after generating the instruction blocks of the json configuration corresponding to each instruction block, collecting and combining the instruction blocks of each json configuration obtained by conversion according to the hierarchical nesting relationship between the instruction blocks in the conf instruction analysis tree and any global information, to obtain the target json configuration corresponding to the conf configuration.

[0055] Reference Figure 3 , showing an execution diagram of a configuration conversion method provided in an embodiment of the present application. In the process of converting instructions one by one and collecting and summarizing global information level by level, when the instruction block includes a single instruction, the json-configured instruction corresponding to the single instruction is generated as a json-configured instruction block according to the target instruction conversion rule.

[0056] When the instruction block is an if instruction block, according to the target instruction conversion rule, any instruction in the if instruction block is converted into an instruction of the json configuration corresponding to the instruction, and according to the collected and summarized configuration information of the if instruction block, the instructions of the json configuration corresponding to any instruction in the if instruction block are combined into an instruction block of the json configuration corresponding to the if instruction block.

[0057] When the instruction block is a location instruction block, according to the target instruction conversion rule, any instruction in the location instruction block is converted into an instruction of the json configuration corresponding to the instruction, and according to the collected and summarized configuration information of the location instruction block, the instructions of the json configuration corresponding to any instruction in the location instruction block are combined into an instruction block of the json configuration corresponding to the location instruction block.

[0058] Reference Figure 4 , shows an execution flow chart of a configuration conversion method provided in an embodiment of the present application. In a feasible implementation, the original conf configuration is first pulled, and then lexical analysis and grammatical analysis are performed in sequence to obtain a conf instruction analysis tree.

[0059] Then enter the sub-process, in which the instruction blocks in the conf instruction analysis tree are traversed, a single instruction in any instruction block is converted, and it is determined whether all instructions in the instruction block have been converted. If not, the next single instruction is obtained for conversion. If so, all the converted instructions in the instruction block are collected and summarized layer by layer to obtain the json configured instruction block corresponding to the instruction block; then the next instruction block is traversed.

[0060] Until all instruction blocks in the conf instruction analysis tree generate corresponding json configuration instruction blocks, exit the sub-process, and collect and combine the converted json configuration instruction blocks according to the hierarchical nesting relationship between the instruction blocks in the conf instruction analysis tree and any global information, to obtain the target json configuration corresponding to the conf configuration, and finally, send the target json configuration to the json hot loading system to take effect.

[0061] In this configuration conversion method, firstly, the conf configuration of the Nginx application of the CDN system is obtained; then, a corresponding conf instruction analysis tree is generated according to the conf configuration, and the conf instruction analysis tree is used to characterize the hierarchical nesting relationship between instruction blocks in the conf configuration; then, according to the conf instruction analysis tree and the target instruction conversion rule, a target json configuration corresponding to the conf configuration is generated, and the target instruction conversion rule is a conversion rule from instructions in the conf configuration to json configuration.

[0062] According to the conf configuration, the conf instruction analysis tree of the conf configuration is obtained, and then the conf configuration is automatically converted into the target json configuration corresponding to the conf configuration. Compared with manually translating the conf configuration file into json configuration, it can not only avoid more errors in the translation process, improve the accuracy of the conversion, but also improve the efficiency of the configuration conversion process.

[0063] In the configuration conversion method provided in this embodiment, a configuration file in json format is generated based on the conversion of the configuration file in conf format to be applied to the json-based Nginx hot loading system. This method does not generate new business configurations for new business needs, but generates a new configuration format based on the original business logic configuration format.

[0064] This method is aimed at the conversion of Nginx's conf configuration. It is similar to the code compilation process. After lexical analysis, syntax analysis, instruction translation, instruction block collection, and final optimization, it is converted into json format. However, unlike general programming language compilation, this method does not compile the code into machine code or bytecode, but converts the conf configuration into the target json configuration to adapt to the json-based Nginx hot loading system.

[0065] And unlike the conversion between different storage formats of the same data, which can be converted one-to-one from xml to json, this method is specifically adapted to completely rearrange the data for Nginx's json hot loading system. Similar to the compilation process, the data content and format need to be completely changed according to the target instruction rules. It is compiled and converted from Nginx's native conf format to a json format that can be used for hot loading of the business logic execution system.

[0066] By automatically converting a large number of conf configurations into target json configurations supported by the json hot loading system, the probability of manual errors is reduced, and complicated and lengthy manual operations are saved. This can accelerate the launch of the Nginx hot loading system and reduce maintenance costs, and enable more standardized and rapid conversion and migration, thereby improving the quality and efficiency of business services.

[0067] Reference Figure 5 , shows a functional module diagram of a configuration conversion device provided in an embodiment of the present application, which is applied to a CDN system, and the device includes: The acquisition module 100 is used to obtain the conf configuration of the Nginx application of the CDN system; A first generating module 200, configured to generate a corresponding conf instruction analysis tree according to the conf configuration, wherein the conf instruction analysis tree is used to represent the hierarchical nesting relationship between instruction blocks in the conf configuration; The second generation module 300 is used to generate a target json configuration corresponding to the conf configuration according to the conf instruction analysis tree and the target instruction conversion rule, wherein the target instruction conversion rule is a conversion rule from instructions in the conf configuration to json configuration.

[0068] Optionally, the first generating module includes: A lexical analysis unit, used for performing lexical analysis on the conf configuration, determining any identifier in the conf configuration, and sequentially composing all identifiers in the conf configuration into an identifier sequence; A syntax analysis unit is used to perform syntax analysis on the identification sequence of the conf configuration, determine any instruction of the conf configuration and the nested relationship between instructions, and generate a conf instruction analysis tree corresponding to the conf configuration, wherein the leaf nodes in the conf instruction analysis tree are instruction blocks corresponding to any business logic, and the instruction block includes at least one instruction.

[0069] Optionally, the second generating module includes: A conversion unit, used for traversing any instruction block in the conf instruction analysis tree, and converting the instruction block into a corresponding json configured instruction block according to the target instruction conversion rule; The combining unit is used to collect and combine the instruction blocks of each json configuration obtained by conversion according to the hierarchical nesting relationship between the instruction blocks of the conf instruction analysis tree, so as to obtain the target json configuration corresponding to the conf configuration.

[0070] Optionally, the conversion unit includes: A traversal subunit, used to traverse any instruction block in the conf instruction analysis tree; A first conversion subunit is used for, when the instruction block includes a single instruction, generating a json-configured instruction corresponding to the single instruction as a json-configured instruction block according to the target instruction conversion rule; A second conversion subunit is used for, when the instruction block is an if instruction block, converting any instruction in the if instruction block into an instruction configured in json corresponding to the instruction according to the target instruction conversion rule, and combining the instructions configured in json corresponding to any instruction in the if instruction block into an instruction block configured in json corresponding to the if instruction block according to the configuration information of the if instruction block, wherein the configuration information of the if instruction block includes the if condition and various configurations in the if instruction block; The third conversion sub-unit is used for, when the instruction block is a location instruction block, converting any instruction in the location instruction block into an instruction configured in json corresponding to the instruction according to the target instruction conversion rule, and combining the instructions configured in json corresponding to any instruction in the location instruction block into an instruction block configured in json corresponding to the location instruction block according to the configuration information of the location instruction block, wherein the configuration information of the location instruction block includes url routing rules.

[0071] Optionally, the conversion unit includes: A traversal subunit, used for traversing any instruction block in the conf instruction analysis tree; The fourth conversion sub-unit is used to generate, for any set response header instruction, a json configuration instruction corresponding to the set response header instruction according to the target instruction conversion rule, and add the json configuration instruction corresponding to the set response header instruction to the response header list, and the response header list is located at the target position of the target json configuration.

[0072] Optionally, the combination unit comprises: A recording subunit, used to record any global information in the conf configuration, wherein the global information includes the global status information of the business domain name configuration; The combining subunit is used to collect and combine the instruction blocks of each json configuration obtained by conversion according to the hierarchical nesting relationship between the instruction blocks of the conf instruction analysis tree and any global information, so as to obtain the target json configuration corresponding to the conf configuration.

[0073] Optionally, the device further comprises: A sending module, used for sending the target json configuration to the json hot loading system of the CDN system; The modification module is used to obtain the configuration to be modified and modify the configuration to be modified in the target json configuration when responding to any configuration modification operation.

[0074] Reference Figure 6 , shows a schematic diagram of a computer device provided in an embodiment of the present application, comprising: at least one processor 601, and a memory 602, wherein the memory 602 stores a computer program that can be run on the processor 601, wherein the processor 601 executes the configuration conversion method described in the embodiment when executing the computer program.

[0075] When the processor 601 executes the computer program, the configuration conversion method described in the embodiment is executed, specifically including the following steps: obtaining the conf configuration of the Nginx application of the CDN system; generating a corresponding conf instruction analysis tree according to the conf configuration, wherein the conf instruction analysis tree is used to characterize the hierarchical nesting relationship between instruction blocks in the conf configuration; generating a target json configuration corresponding to the conf configuration according to the conf instruction analysis tree and a target instruction conversion rule, wherein the target instruction conversion rule is a conversion rule from instructions in the conf configuration to json configuration.

[0076] Reference Figure 7 , shows a schematic diagram of a non-volatile readable storage medium provided in an embodiment of the present application, wherein the non-volatile readable storage medium 700 stores a computer program 701, wherein the computer program 701, when executed by a processor, performs the configuration conversion method described in the embodiment.

[0077] When the computer program 701 is executed by the processor, the configuration conversion method described in the embodiment is executed, specifically including the following steps: obtaining the conf configuration of the Nginx application of the CDN system; generating a corresponding conf instruction analysis tree according to the conf configuration, wherein the conf instruction analysis tree is used to characterize the hierarchical nesting relationship between instruction blocks in the conf configuration; generating a target json configuration corresponding to the conf configuration according to the conf instruction analysis tree and a target instruction conversion rule, wherein the target instruction conversion rule is a conversion rule from instructions in the conf configuration to json configuration.

[0078] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0079] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0080] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0081] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0082] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0083] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.

[0084] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0085] Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A configuration conversion method, characterized in that: Applied to a CDN system, the method includes: Get the conf configuration of the Nginx application of the CDN system; Generate a corresponding conf instruction analysis tree according to the conf configuration, wherein the conf instruction analysis tree is used to represent the hierarchical nesting relationship between instruction blocks in the conf configuration; According to the conf instruction analysis tree and the target instruction conversion rule, a target json configuration corresponding to the conf configuration is generated, and the target instruction conversion rule is a conversion rule from instructions in the conf configuration to json configuration.

2. The method according to claim 1, characterized in that Generate a corresponding conf instruction analysis tree according to the conf configuration, including: Performing lexical analysis on the conf configuration, determining any identifier in the conf configuration, and sequentially composing all identifiers in the conf configuration into an identifier sequence; Perform grammatical analysis on the identification sequence of the conf configuration, determine any instruction of the conf configuration and the nested relationship between instructions, and generate a conf instruction analysis tree corresponding to the conf configuration, wherein the leaf nodes in the conf instruction analysis tree are instruction blocks corresponding to any business logic, and the instruction block includes at least one instruction.

3. The method according to claim 1, characterized in that According to the conf instruction analysis tree and the target instruction conversion rule, the target json configuration corresponding to the conf configuration is generated, including: Traverse any instruction block in the conf instruction analysis tree, and convert the instruction block into a corresponding json configured instruction block according to the target instruction conversion rule; According to the hierarchical nesting relationship between the instruction blocks of the conf instruction analysis tree, the instruction blocks of each json configuration obtained by conversion are collected and combined to obtain the target json configuration corresponding to the conf configuration.

4. The method according to claim 3, characterized in that Traverse any instruction block in the conf instruction analysis tree, and convert the instruction block into a corresponding json-configured instruction block according to the target instruction conversion rule, including: Traverse any instruction block in the conf instruction analysis tree; When the instruction block includes a single instruction, generating a json-configured instruction corresponding to the single instruction as a json-configured instruction block according to the target instruction conversion rule; When the instruction block is an if instruction block, according to the target instruction conversion rule, any instruction in the if instruction block is converted into an instruction of the json configuration corresponding to the instruction, and according to the configuration information of the if instruction block, the instructions of the json configuration corresponding to any instruction in the if instruction block are combined into an instruction block of the json configuration corresponding to the if instruction block, wherein the configuration information of the if instruction block includes the if condition and various configurations in the if instruction block; When the instruction block is a location instruction block, according to the target instruction conversion rule, any instruction in the location instruction block is converted into an instruction configured in json corresponding to the instruction, and according to the configuration information of the location instruction block, the instructions configured in json corresponding to any instruction in the location instruction block are combined into an instruction block configured in json corresponding to the location instruction block, wherein the configuration information of the location instruction block includes url routing rules.

5. The method according to claim 3, characterized in that: Traverse any instruction block in the conf instruction analysis tree, and convert the instruction block into a corresponding json-configured instruction block according to the target instruction conversion rule, including: The process of traversing any instruction block in the conf instruction analysis tree; For any set response header instruction, generate the json configuration instruction corresponding to the set response header instruction according to the target instruction conversion rule, and add the json configuration instruction corresponding to the set response header instruction to the response header list, which is located at the target position of the target json configuration.

6. The method according to claim 3, characterized in that According to the hierarchical nesting relationship between the instruction blocks of the conf instruction analysis tree, the instruction blocks of each json configuration obtained by conversion are collected and combined to obtain the target json configuration corresponding to the conf configuration, including: Record any global information in the conf configuration, the global information including the business domain name configuration global status information; According to the hierarchical nesting relationship between the instruction blocks of the conf instruction analysis tree and any global information, the instruction blocks of each json configuration obtained by conversion are collected and combined to obtain the target json configuration corresponding to the conf configuration.

7. The method according to claim 1, characterized in that After generating the target json configuration corresponding to the conf configuration, the method further includes: Send the target json configuration to the json hot loading system of the CDN system; When responding to any configuration modification operation, the configuration to be modified is obtained, and the configuration to be modified in the target json configuration is modified.

8. A configuration conversion device, characterized in that: Applied to a CDN system, the device comprises: An acquisition module is used to obtain the conf configuration of the Nginx application of the CDN system; A first generating module, used to generate a corresponding conf instruction analysis tree according to the conf configuration, wherein the conf instruction analysis tree is used to represent the hierarchical nesting relationship between instruction blocks in the conf configuration; The second generation module is used to generate a target json configuration corresponding to the conf configuration according to the conf instruction analysis tree and the target instruction conversion rule, and the target instruction conversion rule is a conversion rule from instructions in the conf configuration to json configuration.

9. A computer device, characterized in that: include: At least one processor, and a memory, wherein the memory stores a computer program that can be run on the processor, wherein the processor executes the configuration conversion method according to any one of claims 1 to 7 when executing the computer program.

10. A non-volatile readable storage medium, characterized in that: The non-volatile readable storage medium stores a computer program, wherein the computer program, when executed by a processor, performs the configuration conversion method according to any one of claims 1 to 7.