CN108228268B - Method and device for automatically generating configuration file - Google Patents
Method and device for automatically generating configuration file Download PDFInfo
- Publication number
- CN108228268B CN108228268B CN201611159481.6A CN201611159481A CN108228268B CN 108228268 B CN108228268 B CN 108228268B CN 201611159481 A CN201611159481 A CN 201611159481A CN 108228268 B CN108228268 B CN 108228268B
- Authority
- CN
- China
- Prior art keywords
- configuration file
- template
- processing
- file template
- configuration
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44505—Configuring for program initiating, e.g. using registry, configuration files
- G06F9/4451—User profiles; Roaming
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q10/00—Administration; Management
- G06Q10/08—Logistics, e.g. warehousing, loading or distribution; Inventory or stock management
- G06Q10/087—Inventory or stock management, e.g. order filling, procurement or balancing against orders
Landscapes
- Engineering & Computer Science (AREA)
- Business, Economics & Management (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Economics (AREA)
- Physics & Mathematics (AREA)
- Operations Research (AREA)
- General Business, Economics & Management (AREA)
- Human Resources & Organizations (AREA)
- Quality & Reliability (AREA)
- Strategic Management (AREA)
- Tourism & Hospitality (AREA)
- Entrepreneurship & Innovation (AREA)
- Marketing (AREA)
- Development Economics (AREA)
- Finance (AREA)
- Accounting & Taxation (AREA)
- General Engineering & Computer Science (AREA)
- Stored Programmes (AREA)
- Information Transfer Between Computers (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The present invention relates to the field of computer network technologies, and in particular, to a method and an apparatus for automatically generating a configuration file. A method for automatically generating a configuration file comprises the following steps: downloading a configuration file template; and processing the configuration file template to obtain the required configuration file. The invention can ensure that the multi-warehouse distributed deployment of the same application only needs to configure one configuration file template, dynamically generates the configuration of different warehouses, reduces the labor cost, and further effectively solves the problems of low manual modification efficiency and inapplicability to distributed deployment in the prior art.
Description
Technical Field
The present invention relates to the field of computer network technologies, and in particular, to a method and an apparatus for automatically generating a configuration file.
Background
The warehousing system is distributed and deployed in warehouses, and a whole set of applications such as warehouse-out, warehouse-in, rechecking, goods picking and the like need to be deployed when a warehouse is newly added. The deployment process of these applications is complex, requiring a large amount of deployment, configuration modification, etc. by professionals. Each time a warehouse is newly opened, operation and maintenance personnel are required to modify the configuration files of the corresponding application, such as modifying database connection strings, modifying log file paths, modifying domain names and the like.
The automated configuration for an application is configured on an instance basis: newly building an application example; extracting the configuration file of the application and configuring the corresponding content; and the configured file is issued to the client through the distribution server, and the configuration synchronization is completed. Manual modification may be involved in the process of extracting and configuring the configuration file, and the configuration file cannot be dynamically generated. In the prior art, a configuration file is managed through an example, then is issued to a client and is applied to a warehousing system, and the following defects exist: because the warehouse is deployed in a distributed mode, the functions of application examples are the same, but the contents of configuration files are different, and the prior art is difficult to meet the requirements of multiple deployment environments and different configuration files; in a warehouse environment, the prior art only can create an example for each warehouse, and then create a configuration file in each example, without releasing the labor cost and improving the efficiency; the user experience is poor, the problem can be solved by configuring a small amount of warehouse applications and operating the warehouse applications for a plurality of times, but if the number of warehouses is dozens or hundreds, the time waste, the labor cost waste and the efficiency are low.
Disclosure of Invention
In view of this, the present invention provides a method and an apparatus for automatically generating a configuration file, which can reduce manual intervention, reduce labor cost, reduce tedious labor, improve work efficiency, and reduce maintenance cost of multiple configuration files, thereby reducing error probability. Therefore, the invention solves the problems that the configuration file acquisition in the prior art needs manual intervention and cannot be automatically generated.
To achieve the above object, according to one aspect of the present invention, there is provided a method of automatically generating a configuration file.
The method of the invention comprises the following steps: downloading a configuration file template; and processing the configuration file template to obtain the required configuration file.
Optionally, processing the profile template comprises: processing if functions within the profile template; processing the for function in the configuration file template; replacing relevant variables within the profile template with properties of a library.
Optionally, the method further comprises: creating a configuration file template according to the content of the configuration file required by the application; judging whether a plurality of configuration files need to be generated, if so, dynamically creating a path of the configuration file template as a relative path, otherwise, directly creating the path as the relative path; if the content needing to be repeated exists in the configuration file template, processing by using a for function; and if the content needing to be judged exists in the configuration file template, processing by using an if function.
Optionally, the method further comprises: storing the configuration file template in a file server; and
and acquiring a required configuration file through an application programming interface, and writing the configuration file into a corresponding file in the client.
Optionally, the content of the configuration file required by the application includes, but is not limited to: database cluster information and number, warehouse information, and application configuration information.
According to another aspect of the present invention, there is provided an apparatus for automatically generating a configuration file.
The system of the present invention comprises: the downloading module is used for downloading the configuration file template; and the processing module is used for processing the configuration file template to obtain the required configuration file.
Optionally, the processing module is further configured to: processing if functions within the profile template; processing the for function in the configuration file template; replacing relevant variables within the profile template with properties of a library.
Optionally, the apparatus further comprises a creating module, configured to create a profile template according to content of a profile required by the application; judging whether a plurality of configuration files need to be generated, if so, dynamically creating a path of the configuration file template as a relative path, otherwise, directly creating the path as the relative path; if the repeated content is needed in the configuration file template, processing by using a for function; and if the content needing to be judged exists in the configuration file template, using an if function to process.
Optionally, the apparatus further comprises a storage module, configured to store the configuration file template in a file server; and the acquisition module is used for acquiring the required configuration file through an application programming interface and writing the configuration file into a corresponding file in the client.
Optionally, the content of the configuration file required by the application includes, but is not limited to: database cluster information and number, warehouse information, and application configuration information.
According to still another aspect of the present invention, there is provided an electronic apparatus including: one or more processors; a storage device, configured to store one or more programs, which when executed by the one or more processors, cause the one or more processors to implement the method for automatically generating a configuration file as described above.
According to a further aspect of the present invention, there is provided a computer readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the method for automatically generating a configuration file as described above.
According to the technical scheme of the invention, the configuration file template is downloaded and processed to obtain the required configuration file, namely, the configuration files with different paths and different contents can be generated by using the same configuration file template. For the same application, when the distributed deployment is carried out on different warehouse configuration files, only the configuration file template can be downloaded, and the configuration file template can be automatically processed, so that the problems that the manual modification efficiency is low and the distributed deployment is not suitable in the prior art are effectively solved.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main steps of a method for automatically generating a configuration file according to an embodiment of the present invention;
FIG. 2 is a flow diagram of a method of automatically generating a configuration file, according to an embodiment of the present invention;
fig. 3 is a schematic diagram of main modules of an apparatus for automatically generating a configuration file according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of main steps of a method for automatically generating a configuration file according to an embodiment of the present invention.
As shown in fig. 1, a method for automatically generating a configuration file according to an embodiment of the present invention includes the following main steps:
s11: and downloading the configuration file template. And creating a configuration file template according to the content of the configuration file required by the application, and uploading the created configuration file template to a file server for storage. The content of the configuration file required by the application includes, but is not limited to: database cluster information and number, warehouse information, and application configuration information.
In the embodiment of the invention, the template file comprises the number and information of database clusters, information of a warehouse, application configuration information and the like. Wherein the database cluster information: configuration information of the production library and the report library in the warehouse, for example: IP, port, username, password, etc. Warehouse information: web addresses in the warehouse, cache addresses such as redis, load balancing configuration, and the like. Application configuration information: including application logs, connection pools, bean configurations, etc.
In the process of creating the configuration file template, whether a plurality of configuration files need to be generated is judged, if yes, the path of the configuration file template is dynamically created as a relative path, such as/conf/canalClient- @ { mysql }. properties. Otherwise, it is directly created as a relative path, such as/conf/canaclient/redis. And if the configuration file template has the content needing to be repeated, processing the configuration file template by using a for function, such as @ { fn: for (i, mysql) } xxxxx @ { fn: end }. Some special applications need to generate configuration files with partial differences and different paths according to the number of database clusters, so that dynamic creation is needed, and non-dynamic paths are directly created after the relative paths are directly written.
If the configuration file is managed through the example, the content needing to be repeated needs to be manually operated, and the for function is used for automatic processing in the embodiment of the invention, so that the configuration file can be automatically generated more conveniently. If the content needing to be judged exists in the configuration file template, the processing is carried out by using an if function, namely the processing is carried out by the following expression:
$if()$
xxxx=xxxx
$else$
xxxx=aaaa
$endif$。
s12: and processing the configuration file template to obtain the required configuration file. The configuration file template processing adopts a Stringtemplate method, and the complicated operation of repeated content configuration is reduced by configuring for and if expressions, so that the working efficiency is improved. StringTemplate is a Java-based template engine library (currently supporting C #, Python, Ruby at the same time), and can be used to generate various formatted texts such as source code, Web pages, e-mails, etc.
Processing the profile template includes: processing an if function within the configuration file template; processing a for function in a configuration file template; the properties of the repository are substituted for the relevant variables in the profile template. After downloading the configuration file template from the file server, if the $ symbol is included in the configuration file template, the content between the $ symbol is processed, namely, the if function is processed. The for function is then processed and a new context is generated, and then the variables associated with the library environment are processed. And finally, the storehouse client can acquire the content of the application configuration file through an Application Programming Interface (API) and write the content into a corresponding file. In the embodiment of the present invention, the attribute of the repository includes basic information such as a database IP of the repository, a domain name of the repository, a serial number of the repository, a number of a distribution center, a region code, and the like.
Fig. 2 is a flowchart of a method for automatically generating a configuration file according to an embodiment of the present invention.
As shown in fig. 2, a method for automatically generating a configuration file according to an embodiment of the present invention includes:
s21: and downloading the configuration file template. The created configuration file template is stored in a file server, and when the configuration file template is used, the configuration file template can be downloaded through the file server.
S22: the if function within the profile template is processed. If the $ symbol is included, the content between the $ symbols is processed, because the content of the configuration file template is replaced by the variable, the variable in the template file needs to be replaced before being issued to the warehouse and then being issued to the program for use, and the variable is between the $ symbols. In the embodiment of the present invention, the determining of the if function includes: and judging whether a dynamic path is needed or not, judging the type of the warehouse, and judging whether partial file content needs to be displayed or not.
S23: the for function within the profile template is processed. Unlike the prior art in which duplicate content is processed manually, embodiments of the present invention utilize a for function to process automatically. The for function processes the repeated and small parts of different contents in the template contents of the configuration file, and the contents can be generated according to the specified quantity only by manually maintaining once.
S24: the properties of the repository are substituted for the relevant variables in the profile template. And replacing relevant variables in the configuration file template by using the attribute of the storehouse (warehouse environment variable: key value pair data generated according to warehouse information), wherein keys in the configuration file template are replaced by using the attribute of the storehouse in the operation process.
S25: through the above processing, a desired profile is obtained.
S26: and acquiring the required configuration file through an application programming interface.
S27: and writing the corresponding file to complete the configuration process.
Fig. 3 is a schematic diagram of main modules of an apparatus for automatically generating a configuration file according to an embodiment of the present invention.
As shown in fig. 3, an apparatus 3 for automatically generating a configuration file according to an embodiment of the present invention mainly includes: a download module 31 and a processing module 32. The download module 31 is used for downloading a configuration file template, and the processing module 32 is used for processing the configuration file template to obtain a required configuration file.
The processing module 32 is further configured to process an if function in the profile template, where the created profile template has content that needs to be determined, and the if function is used in the profile template, and when the profile template is used, the if function needs to be processed, and if the $ symbol is included, the content between the $ symbols is processed first. In addition, the processing module 32 is further configured to process the for function in the profile template, so as to process the content in the profile template, which has repeated content and a small portion of content is different. And, the processing module 32 replaces the relevant variables within the profile template with the properties of the repository. In the embodiment of the present invention, the attribute of the repository includes basic information such as a database IP of the repository, a domain name of the repository, a serial number of the repository, a number of a distribution center, a region code, and the like.
The device 3 for automatically generating the configuration file of the embodiment of the invention also comprises a creating module, a generating module and a device for automatically generating the configuration file, wherein the creating module is used for creating a configuration file template according to the content of the configuration file required by the application; judging whether a plurality of configuration files need to be generated, if so, dynamically creating a path of the configuration file template as a relative path, otherwise, directly creating the path as the relative path; if the configuration file template has the content needing to be repeated, processing by using a for function; and if the content needing to be judged exists in the configuration file template, processing by using an if function. The Stringtemplate method is adopted for processing the configuration file template, the complicated operation of repeated configuration of the content is reduced through configuring for and if expressions, and the working efficiency is improved.
In addition, the device 3 for automatically generating a configuration file according to the embodiment of the present invention further includes a storage module and an acquisition module. The storage module is used for storing the configuration file template in the file server; the acquisition module is used for acquiring the required configuration file through the application programming interface and writing the configuration file into a corresponding file in the client. The configuration file templates are created by the creating module and stored in the file server by the storage module, wherein only one configuration file template needs to be configured for multi-warehouse distributed deployment of the same application, and then configuration files of different warehouses can be dynamically generated through processing of the downloading module and the processing module, so that manual intervention can be reduced, labor cost can be reduced, tedious labor can be reduced, and further work efficiency can be improved. Moreover, the maintenance cost of multiple configuration files is reduced, and the error probability is reduced.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (6)
1. A method for automatically generating a configuration file, comprising:
downloading a configuration file template;
processing the configuration file template to obtain a required configuration file;
creating a configuration file template according to the content of the configuration file required by the application; the content of the configuration file required by the application includes: information and number of database clusters, information of warehouses and application configuration information;
in the process of creating the configuration file template, judging whether a plurality of configuration files need to be generated or not according to the number of the database clusters, if so, dynamically creating the path of the configuration file template as a relative path, otherwise, directly creating the path as the relative path; and the number of the first and second groups,
if the content needing to be repeated exists in the configuration file template, processing by using a for function; if the configuration file template has the content needing to be judged, using an if function for processing;
the configuration file template processing adopts a Stringtemplate method;
processing the profile template includes:
processing the if function in the configuration file template, and if the configuration file template contains the $ symbol, firstly processing the content between the $ symbol;
processing the for function in the configuration file template;
replacing relevant variables within the profile template with properties of a library.
2. The method of claim 1, further comprising:
storing the configuration file template in a file server; and
and acquiring a required configuration file through an application programming interface, and writing the configuration file into a corresponding file in the client.
3. An apparatus for automatically generating a configuration file, comprising:
the downloading module is used for downloading the configuration file template; and
a processing module for processing the configuration file template to obtain a required configuration file; the configuration file template processing adopts a Stringtemplate method;
the creating module is used for creating a configuration file template according to the content of the configuration file required by the application; the content of the configuration file required by the application includes: information and number of database clusters, information of warehouses and application configuration information;
in the process of creating the configuration file template, judging whether a plurality of configuration files need to be generated or not according to the number of the database clusters, if so, dynamically creating the path of the configuration file template as a relative path, otherwise, directly creating the path as the relative path; and the number of the first and second groups,
if the content needing to be repeated exists in the configuration file template, processing by using a for function; if the configuration file template has the content needing to be judged, using an if function for processing;
the processing module is further configured to: processing the if function in the configuration file template, and if the configuration file template contains the $ symbol, firstly processing the content between the $ symbol; processing the for function in the configuration file template; replacing relevant variables within the profile template with properties of a library.
4. The apparatus of claim 3, further comprising:
the storage module is used for storing the configuration file template in the file server; and
and the acquisition module is used for acquiring the required configuration file through an application programming interface and writing the configuration file into a corresponding file in the client.
5. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-2.
6. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-2.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611159481.6A CN108228268B (en) | 2016-12-15 | 2016-12-15 | Method and device for automatically generating configuration file |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611159481.6A CN108228268B (en) | 2016-12-15 | 2016-12-15 | Method and device for automatically generating configuration file |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108228268A CN108228268A (en) | 2018-06-29 |
CN108228268B true CN108228268B (en) | 2021-11-12 |
Family
ID=62651329
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201611159481.6A Active CN108228268B (en) | 2016-12-15 | 2016-12-15 | Method and device for automatically generating configuration file |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108228268B (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110889656B (en) * | 2018-09-11 | 2024-04-19 | 北京京东振世信息技术有限公司 | Warehouse rule configuration method and device |
CN112288344A (en) * | 2019-07-24 | 2021-01-29 | 北京京东乾石科技有限公司 | Scheduling task data processing method, device, equipment and storage medium |
CN110795142B (en) * | 2019-10-18 | 2023-04-07 | 郑州阿帕斯科技有限公司 | Configuration file generation method and device |
CN111159162B (en) * | 2019-12-31 | 2023-07-25 | 中国联合网络通信集团有限公司 | Database configuration method and equipment |
CN113055502B (en) * | 2021-02-08 | 2022-07-29 | 中国电子科技集团公司第十五研究所 | Automatic domain name registration method suitable for private cloud |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102811447A (en) * | 2011-05-31 | 2012-12-05 | 中兴通讯股份有限公司 | Method, device and system for configuring base station data |
CN103516529A (en) * | 2012-06-20 | 2014-01-15 | 中兴通讯股份有限公司 | Management method, device and system of configuration files |
CN103530135A (en) * | 2013-10-31 | 2014-01-22 | 深圳中兴网信科技有限公司 | Proxy service generating device and proxy service generating method |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104468148B (en) * | 2013-09-12 | 2019-03-22 | 中兴通讯股份有限公司 | A kind of nginx server configuring maintenance method and system |
US9473356B2 (en) * | 2013-09-30 | 2016-10-18 | Oracle International Corporation | Automatic configuration of applications based on host metadata using application-specific templates |
-
2016
- 2016-12-15 CN CN201611159481.6A patent/CN108228268B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102811447A (en) * | 2011-05-31 | 2012-12-05 | 中兴通讯股份有限公司 | Method, device and system for configuring base station data |
CN103516529A (en) * | 2012-06-20 | 2014-01-15 | 中兴通讯股份有限公司 | Management method, device and system of configuration files |
CN103530135A (en) * | 2013-10-31 | 2014-01-22 | 深圳中兴网信科技有限公司 | Proxy service generating device and proxy service generating method |
Also Published As
Publication number | Publication date |
---|---|
CN108228268A (en) | 2018-06-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108228268B (en) | Method and device for automatically generating configuration file | |
US11663257B2 (en) | Design-time information based on run-time artifacts in transient cloud-based distributed computing clusters | |
CN107958057B (en) | Code generation method and device for data migration in heterogeneous database | |
US20200065136A1 (en) | Design-time information based on run-time artifacts in a distributed computing cluster | |
CN106843837A (en) | The construction method of openstack assembly containers | |
CN102135938A (en) | Software product testing method and system | |
CA2845105A1 (en) | Method for producing plc and hmi tag database and system | |
CN104298588A (en) | Continuous integration implementation method and device | |
CN103177329A (en) | Rule-based determination and validation in business object processing | |
CN105843871B (en) | Control and management system of distributed application files | |
CN105278991A (en) | Construction method of cloud application deployment and configuration model | |
CN111061743B (en) | Data processing method and device and electronic equipment | |
CN103984769A (en) | Use-case data management and storage method | |
US20240126787A1 (en) | System and method for data pruning via dynamic partition management | |
US20190332360A1 (en) | Enterprise Services Framework for Presentation Layer Management | |
JP7131119B2 (en) | Systems and methods for merging source data from a source application with target data in a target application | |
CN105354671A (en) | Universal configuration management system and enterprise-level information system comprising same | |
CN112905225A (en) | Method and device for creating continuous integration tool construction task | |
CN104750849A (en) | Method and system for maintaining tree structure-based directory relationship | |
US11061859B2 (en) | Object creation from hierarchical metadata stored on a storage device | |
US20150295985A1 (en) | Modification Free Extension of Web Based Applications | |
AU2018313995B2 (en) | Systems and methods for providing globalization features in a service management application interface | |
US11750458B1 (en) | Structured network change controls | |
US11017008B2 (en) | Method and system for contextualizing process data | |
CN110580159A (en) | automatic software code generation method and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |