OpenResty configuration file generation method and device
By generating OpenResty configuration files, using the corresponding relationship between custom keywords and server configuration properties, the problem that OpenResty configuration files cannot be modified in differentiatedly is solved, and personalized configuration files are generated according to server configuration.
Patent Information
- Application Number
- CN202310390695.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-13
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2043-04-13
AI Technical Summary
The prior art cannot differentiate the modification of OpenResty configuration files based on different hardware and/or software configurations of the server.
The configuration content data is obtained based on the configuration content and custom keywords required by OpenResty, and the index data is generated based on the configuration properties of the deployment server. Finally, the OpenResty configuration file is generated based on the configuration content data and index data.
Differentiated modification of OpenResty configuration files is implemented according to different hardware and/or software configurations of the server, solving the problem that configuration file modifications cannot be differentiated in the prior art.
Smart Images

Figure CN116405381B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network security technology, and in particular to a method and device for generating an OpenResty configuration file. Background Art
[0002] OpenResty is a high-performance Web platform based on Nginx and Lua, which integrates a large number of sophisticated Lua libraries, third-party modules, and most dependencies. OpenResty is used to easily build dynamic Web applications, Web services, and dynamic gateways that can handle ultra-high concurrency and high scalability. Therefore, the industry is using OpenResty more and more.
[0003] When using OpenResty, users sometimes need to modify the OpenResty configuration file to adapt to the current functional requirements. The modifications include the number of processes used by OpenResty, the port number listened to, etc. One way to modify the OpenResty configuration file in the prior art is to automatically synchronize the modified OpenResty configuration file in full through puppet. This method is suitable for global non-differential modification and cannot perform differentiated modification on the OpenResty configuration file according to different hardware or software configurations of the server. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a method and device for generating an OpenResty configuration file, so as to overcome the problem in the prior art that the OpenResty configuration file cannot be modified differentially according to different hardware and / or software configurations of the server.
[0005] The first aspect of the embodiment of the present application discloses a method for generating an OpenResty configuration file, the method comprising:
[0006] Obtain OpenResty configuration content data according to the configuration content required by OpenResty and at least one custom keyword; wherein one of the custom keywords is used to represent a parameter value corresponding to an OpenResty configuration field;
[0007] Generate index data according to the configuration attributes of the deployment server and the custom keyword; wherein the index data is used to characterize the corresponding relationship between the custom keyword and the configuration parameter value of the deployment server;
[0008] Generate an OpenResty configuration file according to the OpenResty configuration content data and the index data.
[0009] A second aspect of an embodiment of the present application discloses a device for generating an OpenResty configuration file, the device comprising:
[0010] A parameter value replacement module, used to obtain OpenResty configuration content data according to the configuration content required by OpenResty and at least one custom keyword; wherein one of the custom keywords is used to represent a parameter value corresponding to an OpenResty configuration field;
[0011] An index generation module, used to generate index data according to the configuration attributes of the deployment server and the custom keyword; wherein the index data is used to characterize the corresponding relationship between the custom keyword and the configuration parameter value of the deployment server;
[0012] The configuration file generation module is used to generate an OpenResty configuration file according to the OpenResty configuration content data and the index data.
[0013] In an embodiment of the present invention, firstly, according to the configuration content required by OpenResty and at least one custom keyword, the OpenResty configuration content data is obtained; then, according to the configuration properties of the deployment server and the custom keyword, the index data is generated; and then, according to the OpenResty configuration content data and the index data, the OpenResty configuration file is generated. By setting at least one custom keyword and setting the correspondence between the custom keyword and the configuration parameter value of the deployment server, the static data used to characterize the fixed content in the OpenResty configuration file and the dynamic data used to characterize the variable parameter value corresponding to the OpenResty configuration field are separated, so that the parameter values corresponding to all or part of the configuration fields of OpenResty can be modified according to the configuration properties of the deployment server, so as to solve the problem of differential modification of the OpenResty configuration file according to different hardware and / or software configurations of the server. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments 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 creative work.
[0015] Figure 1 It is a flowchart of a method for generating an OpenResty configuration file disclosed in Example 1 of the present application;
[0016] Figure 2It is a flowchart of a method for generating an OpenResty configuration file disclosed in Example 2 of the present application;
[0017] Figure 3 It is a flowchart of a method for generating an OpenResty configuration file disclosed in Example 3 of the present application;
[0018] Figure 4 It is a structural schematic block diagram of an OpenResty configuration file generation device disclosed in Example 4 of the present application. DETAILED DESCRIPTION
[0019] 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 only 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.
[0020] It should be noted that the terms "first", "second", "third" and "fourth" in the specification and claims of the present application are used to distinguish different objects rather than to describe a specific order. The terms "including" and "having" in the embodiments of the present application and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment including a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0021] Embodiment 1
[0022] like Figure 1 As shown, Figure 1 This is a schematic flowchart of a method for generating an OpenResty configuration file disclosed in Embodiment 1 of the present application. The method for generating an OpenResty configuration file includes:
[0023] Step S101, obtaining OpenResty configuration content data according to the configuration content required by OpenResty and at least one custom keyword.
[0024] In this embodiment, the type of the implementation subject is not limited and can be reasonably selected according to actual application requirements. Specifically, the implementation subject can be a deployment server that needs to deploy the OpenResty platform, or other devices that can perform data transmission with the deployment server.
[0025] In this embodiment, when the implementation subject is other devices that can transmit data with the deployment server, the data generated by it can be transmitted to the deployment server, so that the server can configure the relevant parameters of the OpenResty platform according to the received data. In addition, the communication method between the implementation subject of this embodiment and the deployment server is not limited, and can be reasonably selected according to actual application requirements. For example, the implementation subject of this embodiment can communicate data with the deployment server through the http protocol or any other communication protocol, and can also transfer data to the deployment server through storage media such as U disk and mobile hard disk.
[0026] In this embodiment, the configuration content required by OpenResty refers to the content required for normal deployment and use of the OpenResty platform, which usually includes multiple configuration fields, each of which has a corresponding parameter value. Among them, the specific content included in the configuration required by OpenResty is not limited, and can be reasonably selected according to actual application requirements.
[0027] In this embodiment, a custom keyword is used to represent at least a parameter value corresponding to an OpenResty configuration field. The parameter values corresponding to multiple OpenResty configuration fields can be replaced with the same or different custom keywords, and the character type and length representing the custom keyword are not limited, and can be reasonably selected according to actual application requirements. For example, a custom keyword can be a string composed of multiple letters, or a string composed of letters and numbers.
[0028] In this embodiment, the OpenResty configuration content data is used to represent at least all custom keywords. When a parameter value corresponding to an OpenResty configuration field is represented by a custom keyword, the parameter value corresponding to the configuration field can be modified differently according to the hardware and / or software configuration of the deployment server. In this embodiment, there is no limitation on the number of custom keywords and the parameter value corresponding to which OpenResty configuration field is represented by each custom keyword, and a reasonable selection can be made according to actual application requirements.
[0029] Step S102: Generate index data according to the configuration attributes of the deployment server and the custom keywords.
[0030] In this embodiment, since the hardware and / or software configurations of different deployment servers may be different, when generating an OpenResty configuration file for a certain deployment server, it is necessary to generate index data according to the configuration properties of the deployment server.
[0031] In this embodiment, the index data is used to characterize the correspondence between the custom keywords and the configuration parameter values of the deployment server, that is, each custom keyword corresponds to a configuration parameter value of a deployment server. The corresponding custom keywords can be replaced with the configuration parameter values of the deployment server in the OpenResty configuration content data to obtain the OpenResty configuration file of the deployment server. The specific format of the index data is not limited and can be reasonably selected according to actual application requirements.
[0032] Optionally, in order to reduce the amount of data and facilitate corresponding data processing, the index data may preferably use a key-value pair to represent the corresponding relationship between each custom keyword and the configuration parameter value of the deployment server. The custom keyword may be set as the key in the key-value pair, and the configuration parameter value of the deployment server may be set as the value in the key-value pair.
[0033] Furthermore, the format of the index data may preferably be a yaml format or a json format.
[0034] The suffix of the YAML file is ".yml" or ".yaml". YAML is a highly readable format used to express data sequences. For example, when the custom keyword is "whether_sendfile", the corresponding configuration parameter value of the deployment server can be set to "on". The index data can be recorded as "whether_sendfile:on" in YAML format.
[0035] JSON (JavaScript Object Notation) is a lightweight data exchange format with a concise and clear hierarchical structure. It is easy to read and write, and is also easy to machine parse and generate, which helps improve network transmission efficiency.
[0036] In this embodiment, the configuration parameter value of the deployment server is set in any way and can be reasonably selected according to actual application requirements. For example, it can be issued by a third-party service or dynamically configured according to the hardware and / or software configuration of the deployment server.
[0037] Step S103, generating an OpenResty configuration file according to the OpenResty configuration content data and index data.
[0038] In this embodiment, the OpenResty configuration file is used to configure the OpenResty platform for the first time or non-first time. When configuring different OpenResty platforms, some of the contents recorded in the OpenResty configuration file are the same, such as the field name corresponding to each configuration field. This part of fixed data can be called static data; the parameter values corresponding to all or part of the OpenResty configuration fields can be adjusted accordingly according to the hardware and / or software configuration of each deployment server. This part of variable data can be called dynamic data. In step S103, the OpenResty configuration content data and index data are mainly used to update the dynamic data to generate the OpenResty configuration file of the deployment server.
[0039] In this embodiment, the custom keywords in the OpenResty configuration content data can be replaced with the configuration parameter values of the deployment server according to the index data, and an OpenResty configuration file can be generated. After the configuration server obtains the OpenResty configuration file, the OpenResty configuration file can be used to configure the relevant configuration parameters of the OpenResty platform for the first time or not for the first time.
[0040] As can be seen from the above embodiments of the present invention, in the embodiments of the present invention, firstly, according to the configuration content required by OpenResty and at least one custom keyword, the OpenResty configuration content data is obtained; then, according to the configuration properties of the deployment server and the custom keywords, the index data is generated; and then, according to the OpenResty configuration content data and the index data, the OpenResty configuration file is generated. By setting at least one custom keyword and setting the correspondence between the custom keyword and the configuration parameter value of the deployment server, the static data used to characterize the fixed content in the OpenResty configuration file and the dynamic data used to characterize the variable parameter value corresponding to the OpenResty configuration field are separated, so that the parameter values corresponding to all or part of the configuration fields of OpenResty can be modified according to the configuration properties of the deployment server, so as to solve the problem of differential modification of the OpenResty configuration file according to different hardware and / or software configurations of the server.
[0041] Embodiment 2
[0042] like Figure 2 As shown, Figure 2 This is a schematic flowchart of a method for generating an OpenResty configuration file disclosed in Embodiment 2 of the present application. The method for generating an OpenResty configuration file includes:
[0043] Step S201, generating initial configuration content data according to the configuration content required by OpenResty.
[0044] In this embodiment, the initial configuration content data is at least used to represent the parameter values corresponding to all OpenResty configuration fields, that is, the initial configuration content data includes dynamic data for representing the variable parameter values corresponding to the OpenResty configuration fields, and static data for representing fixed content such as field names in the OpenResty configuration file.
[0045] Step S202: According to at least one custom keyword, replace a parameter value corresponding to at least one OpenResty configuration field in the initial configuration content data to obtain OpenResty configuration content data.
[0046] In this embodiment, one custom keyword can replace at least one parameter value corresponding to an OpenResty configuration field. In step S202, at least one custom keyword can be used to replace all or part of the parameter values corresponding to the OpenResty configuration fields.
[0047] In this embodiment, the OpenResty configuration content data also includes dynamic data for representing variable parameter values corresponding to the OpenResty configuration fields, and static data for representing fixed content in the OpenResty configuration file. The OpenResty configuration content data is obtained by replacing the parameter values corresponding to all or part of the OpenResty configuration fields in the initial configuration content data with at least one custom keyword.
[0048] Optionally, in order to avoid the phenomenon that the characters corresponding to the custom keywords overlap with some characters represented in the initial configuration content data, and characters that should not be modified and replaced are modified and replaced in subsequent steps, resulting in the generated OpenResty configuration file not being able to run normally, the custom keywords can be identified by setting start and end characters.
[0049] Specifically, step S202 may include:
[0050] Sub-step A1, generating at least one replacement character string according to all the custom keywords, the custom start character and the custom end character.
[0051] In each replacement string, there is a custom start character, a custom keyword, and a custom end character, and the custom start character, the custom keyword, and the custom end character are set in sequence. In different replacement strings, the custom start character, the custom keyword, and the custom end character can be partially or completely the same, or completely different, and the specific symbol types of the custom start character and the custom end character are not limited, and can be reasonably selected according to actual application requirements.
[0052] For example, you can set the custom start character to "{*" and the custom end character to "*}". If the custom keyword is "whether_sendfile", the replacement string is "{*whether_sendfile*}".
[0053] Optionally, in order to facilitate identification of the custom start character and the custom end character to improve data processing efficiency, it is preferred that the custom start character and the custom end character in all replacement character strings are the same.
[0054] Sub-step A2: using a replacement string, replace a parameter value corresponding to at least one OpenResty configuration field in the initial configuration content data to obtain OpenResty configuration content data.
[0055] Step S203: Generate index data according to the configuration attributes of the deployment server and the custom keywords, wherein the index data is used to characterize the corresponding relationship between the custom keywords and the configuration parameter values of the deployment server.
[0056] In this embodiment, step S203 is substantially the same as or similar to step S102 in the aforementioned first embodiment, and will not be described in detail herein.
[0057] Step S204: Generate an OpenResty configuration file according to the OpenResty configuration content data and index data.
[0058] Optionally, in order to avoid the phenomenon that the custom start character and the custom end character do not appear in pairs in the OpenResty configuration content data in actual applications, resulting in the inability to execute subsequent steps or execution errors, the OpenResty configuration content data can be tested using a legitimacy detection algorithm. Only when the legitimacy detection passes can the OpenResty configuration content data and index data be further used to generate an OpenResty configuration file. Specifically, step S204 can also include the following sub-steps B1-B2:
[0059] Sub-step B1, using a preset legitimacy detection algorithm, performs a legitimacy detection on all replacement strings in the OpenResty configuration content data.
[0060] The legality detection algorithm is used to detect whether all replacement strings in the OpenResty configuration content data are legal, and can also be used to detect whether other contents in the OpenResty configuration content data are legal. The specific type of legality detection algorithm is not limited and can be reasonably selected according to actual application requirements.
[0061] Sub-step B2, when it is determined by using a preset legality detection algorithm that all replacement strings in the OpenResty configuration content data are legal, an OpenResty configuration file is generated according to the OpenResty configuration content data and the index data.
[0062] Furthermore, in order to successfully generate the OpenResty configuration file, step S204 may further include sub-step B3: when it is determined by using a preset legitimacy detection algorithm that at least one replacement string in the OpenResty configuration content data is illegal, an early warning prompt is issued.
[0063] The user may modify the OpenResty configuration content data according to the warning prompt, and execute sub-step B1 again to determine whether the modified OpenResty configuration content data is legal.
[0064] Furthermore, in order to efficiently perform a validity check on all replacement strings in the OpenResty configuration content data, it is preferred that the custom start character includes at least a left bracket, the custom end character includes at least a right bracket, and the validity check algorithm is a valid bracket algorithm.
[0065] Among them, using an effective bracket algorithm can at least determine whether the types of the left bracket and the right bracket meet the preset conditions, and whether the left bracket and the right bracket are closed in the correct order.
[0066] In addition, the specific types of the left bracket and the right bracket are not limited and can be reasonably selected according to actual application requirements. For example, the left bracket can be at least one of "{", "(", "[", and the right bracket can be at least one of "}", ")", "]".
[0067] Optionally, in order to accurately replace the custom keywords with the configuration parameter values of the deployment server, the replacement may be performed step by step in a preset order. Specifically, step S204 may also include the following sub-steps C1 to C3:
[0068] Sub-step C1, reading all characters represented by the OpenResty configuration content data in a preset order, and determining at least one target keyword.
[0069] The OpenResty configuration content data may include one or more replacement strings, that is, one or more custom keywords and one or more corresponding custom start characters and custom end characters. The target keyword is a custom keyword located between a custom start character and a custom end character.
[0070] The preset order is not limited and can be reasonably selected according to actual application requirements. For example, it can be a front-to-back order or a back-to-front order.
[0071] Sub-step C2, determining the configuration parameter value corresponding to each target keyword according to the index data.
[0072] Among them, since the index data is used to characterize the correspondence between the custom keywords and the configuration parameter values of the deployment server, after the target keywords are determined, the configuration parameter value of the deployment server corresponding to each target keyword can be determined according to the index data.
[0073] Sub-step C3, using the configuration parameter value corresponding to each target keyword, replace each target string in the OpenResty configuration content data.
[0074] The target string is one or more of all replacement strings, that is, in each target string, the custom start character, target keyword, and custom end character are also set in sequence. Through sub-step C3, the target keyword, as well as the custom start character and custom end character of the replacement string composed of the target keyword can be replaced together using the configuration parameter value corresponding to each target keyword, so as to generate the OpenResty configuration file required for the deployment server.
[0075] For example, if the custom start character is "{*" and the custom end character is "*}", during the execution of sub-steps C1 to C3, if the start character "{*" is encountered, "{*" is pushed into the stack, and if the end character "*}" is encountered, "*}" is popped out of the stack, and the custom keyword between "{*" and "*}" is determined as the target keyword; then the target keyword is used as the key value, and the corresponding value is found using the index data, and the value is used to replace the target string composed of "{*", the target keyword and "*}".
[0076] It can be seen from the above embodiments of the present invention that the embodiments of the present invention obtain OpenResty configuration content data by generating initial configuration content data and replacing the parameter value corresponding to at least one OpenResty configuration field in the initial configuration content data. The static data used to characterize the fixed content in the OpenResty configuration file and the dynamic data used to characterize the variable parameter values corresponding to the OpenResty configuration fields can be freely combined and separated. Compared with the aforementioned embodiment one, the generation efficiency of the OpenResty configuration file can be improved.
[0077] Embodiment 3
[0078] like Figure 3 As shown, Figure 3 This is a schematic flow chart of a method for generating an OpenResty configuration file disclosed in Example 3 of the present application. The method for generating an OpenResty configuration file includes:
[0079] Step S301, deploying a conversion service program on a deployment server.
[0080] In this embodiment, the conversion service program is used to generate an OpenResty configuration file according to the received OpenResty configuration content data and index data. By deploying the deployment conversion service program on the server, the first device that can perform data transmission with the deployment server can perform differential modification on the OpenResty configuration files of multiple different deployment servers.
[0081] Step S302: The first device obtains OpenResty configuration content data according to the configuration content required by OpenResty and at least one custom keyword.
[0082] In this embodiment, step S302 is substantially the same as or similar to step S101 in the aforementioned embodiment 1, and / or step S201 - step S202 in the aforementioned embodiment 2, and will not be described in detail herein.
[0083] Step S303: The first device generates index data according to the configuration attributes of the deployment server and the custom keywords, wherein the index data is used to characterize the corresponding relationship between the custom keywords and the configuration parameter values of the deployment server.
[0084] In this embodiment, step S303 is substantially the same as or similar to step S102 in the first embodiment, and will not be described in detail herein.
[0085] Step S304: The first device transmits the OpenResty configuration content data and index data to the deployment server.
[0086] In this embodiment, data can be transmitted between the first device and the deployment server. Therefore, after generating OpenResty configuration content data and index data, the first device can transmit the OpenResty configuration content data and index data to the deployment server.
[0087] Step S305: The conversion service program on the deployment server generates an OpenResty configuration file according to the OpenResty configuration content data and index data.
[0088] In this embodiment, step S305 is substantially the same as or similar to step S103 in the aforementioned embodiment 1 and / or step S204 in the aforementioned embodiment 2, and will not be described in detail herein.
[0089] It can be seen from the above embodiments of the present invention that the embodiments of the present invention pre-deploy a conversion service program on the deployment server for generating an OpenResty configuration file based on OpenResty configuration content data and index data, so that the first device that transmits data with the deployment server can perform differential modifications to the OpenResty configuration files of multiple different deployment servers.
[0090] Embodiment 4
[0091] Embodiment 4 of the present application provides a device for generating an OpenResty configuration file. Figure 4 This is a schematic diagram of the structure of an OpenResty configuration file generation device disclosed in Embodiment 4 of the present application, the device comprising:
[0092] The parameter value replacement module is used to obtain the OpenResty configuration content data according to the configuration content required by OpenResty and at least one custom keyword; wherein a custom keyword is used to represent the parameter value corresponding to an OpenResty configuration field;
[0093] An index generation module, used to generate index data according to the configuration attributes of the deployment server and the custom keywords; wherein the index data is used to characterize the corresponding relationship between the custom keywords and the configuration parameter values of the deployment server;
[0094] The configuration file generation module is used to generate the OpenResty configuration file according to the OpenResty configuration content data and index data.
[0095] Optionally, the parameter value replacement module includes a content data generation submodule and a replacement submodule, wherein:
[0096] The content data generation submodule is used to generate initial configuration content data according to the configuration content required by OpenResty; wherein the initial configuration content data is used to represent the parameter values corresponding to all OpenResty configuration fields;
[0097] The replacement submodule is used to replace the parameter value corresponding to at least one OpenResty configuration field in the initial configuration content data according to all custom keywords to obtain OpenResty configuration content data.
[0098] Optionally, the replacement submodule is further used to generate at least one replacement string according to all the custom keywords, the custom start symbol and the custom end symbol; wherein in each replacement string, the custom start symbol, the custom keyword and the custom end symbol are set in sequence;
[0099] The parameter value corresponding to at least one OpenResty configuration field in the initial configuration content data is replaced by using the replacement string to obtain the OpenResty configuration content data.
[0100] Optionally, the configuration file generation module is further used to generate an OpenResty configuration file according to the OpenResty configuration content data and the index data when it is determined by a preset legitimacy detection algorithm that all replacement strings in the OpenResty configuration content data are legal.
[0101] Optionally, the custom start character includes at least a left bracket, the custom end character includes at least a right bracket, and the legality detection algorithm is a valid bracket algorithm.
[0102] Optionally, the configuration file generation module is further used to read all characters represented by the OpenResty configuration content data in a preset order to determine at least one target keyword; wherein the target keyword is a custom keyword located between a custom start character and a custom end character;
[0103] Determine the configuration parameter value corresponding to each target keyword based on the index data;
[0104] Each target string in the OpenResty configuration content data is replaced by the configuration parameter value corresponding to each target keyword; wherein in each target string, the custom start character, the target keyword, and the custom end character are set in sequence.
[0105] Optionally, the index data is in YAML or JSON format.
[0106] Through the OpenResty configuration file generation device of this embodiment, the corresponding OpenResty configuration file generation methods in the aforementioned multiple method embodiments can be implemented, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0107] So far, specific embodiments of the present application have been described. Other embodiments are within the scope of the appended claims. In some cases, the actions recorded in the claims can be performed in a different order and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing can be advantageous.
[0108] The present application is described with reference to the flowcharts and / or block diagrams of the methods according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks 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 device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing 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.
[0109] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or 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, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0110] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods and devices. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program code.
[0111] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0112] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A method for generating an OpenResty configuration file, characterized in that: The method comprises: Obtain OpenResty configuration content data according to the configuration content required by OpenResty and at least one custom keyword; wherein one of the custom keywords is used to represent at least a parameter value corresponding to an OpenResty configuration field; Generate index data according to the configuration attributes of the deployment server and the custom keyword; wherein the index data is used to characterize the corresponding relationship between the custom keyword and the configuration parameter value of the deployment server; Generate an OpenResty configuration file according to the OpenResty configuration content data and the index data; The obtaining of OpenResty configuration content data according to the configuration content required by OpenResty and at least one custom keyword includes: Generate initial configuration content data according to the configuration content required by OpenResty; wherein the initial configuration content data is at least used to represent parameter values corresponding to all the OpenResty configuration fields; According to at least one of the custom keywords, a parameter value corresponding to at least one of the OpenResty configuration fields in the initial configuration content data is replaced to obtain the OpenResty configuration content data.
2. The method according to claim 1, characterized in that The step of replacing a parameter value corresponding to at least one of the OpenResty configuration fields in the initial configuration content data according to at least one of the custom keywords to obtain the OpenResty configuration content data comprises: Generate at least one replacement string according to all of the custom keywords, custom start characters and custom end characters; wherein in each of the replacement strings, the custom start character, the custom keyword and the custom end character are set in sequence; The parameter value corresponding to at least one of the OpenResty configuration fields in the initial configuration content data is replaced by using the replacement string to obtain the OpenResty configuration content data.
3. The method according to claim 2, characterized in that The generating the OpenResty configuration file according to the OpenResty configuration content data and the index data comprises: When it is determined by using a preset legality detection algorithm that all of the replacement character strings in the OpenResty configuration content data are legal, an OpenResty configuration file is generated according to the OpenResty configuration content data and the index data.
4. The method according to claim 3, characterized in that: The custom start symbol at least includes a left bracket, the custom end symbol at least includes a right bracket, and the legality detection algorithm is a valid bracket algorithm.
5. The method according to claim 2, characterized in that: The generating the OpenResty configuration file according to the OpenResty configuration content data and the index data comprises: Reading all characters represented by the OpenResty configuration content data in a preset order to determine at least one target keyword; wherein the target keyword is the custom keyword located between one of the custom start characters and one of the custom end characters; Determine the configuration parameter value corresponding to each target keyword according to the index data; Each target character string in the OpenResty configuration content data is replaced by the configuration parameter value corresponding to each target keyword; wherein in each target character string, the custom start character, the target keyword and the custom end character are set in sequence.
6. The method according to claim 1, characterized in that The index data is in yaml or json format.
7. The method according to claim 1, characterized in that The method further comprises: deploying a conversion service program on the deployment server; Correspondingly, generating an OpenResty configuration file according to the OpenResty configuration content data and the index data includes: The OpenResty configuration content data and the index data are transmitted to the deployment server, so that the conversion service program can generate the OpenResty configuration file according to the OpenResty configuration content data and the index data.
8. An OpenResty configuration file generation device, characterized in that: The device comprises: A parameter value replacement module, used to obtain OpenResty configuration content data according to the configuration content required by OpenResty and at least one custom keyword; wherein one of the custom keywords is used to represent a parameter value corresponding to an OpenResty configuration field; An index generation module, used to generate index data according to the configuration attributes of the deployment server and the custom keyword; wherein the index data is used to characterize the corresponding relationship between the custom keyword and the configuration parameter value of the deployment server; A configuration file generation module, used to generate an OpenResty configuration file according to the OpenResty configuration content data and the index data; The parameter value replacement module includes a content data generation submodule and a replacement submodule, wherein the content data generation submodule is used to generate initial configuration content data according to the configuration content required by OpenResty; wherein the initial configuration content data is used to represent the parameter values corresponding to all the OpenResty configuration fields; The replacement submodule is used to replace a parameter value corresponding to at least one of the OpenResty configuration fields in the initial configuration content data according to all of the custom keywords to obtain the OpenResty configuration content data.