CN108228268A - A kind of method and apparatus for automatically generating configuration file - Google Patents

A kind of method and apparatus for automatically generating configuration file Download PDF

Info

Publication number
CN108228268A
CN108228268A CN201611159481.6A CN201611159481A CN108228268A CN 108228268 A CN108228268 A CN 108228268A CN 201611159481 A CN201611159481 A CN 201611159481A CN 108228268 A CN108228268 A CN 108228268A
Authority
CN
China
Prior art keywords
configuration file
profile template
template
file
functions
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.)
Granted
Application number
CN201611159481.6A
Other languages
Chinese (zh)
Other versions
CN108228268B (en
Inventor
李辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201611159481.6A priority Critical patent/CN108228268B/en
Publication of CN108228268A publication Critical patent/CN108228268A/en
Application granted granted Critical
Publication of CN108228268B publication Critical patent/CN108228268B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • G06F9/4451User profiles; Roaming
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION 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/00Administration; Management
    • G06Q10/08Logistics, e.g. warehousing, loading or distribution; Inventory or stock management
    • G06Q10/087Inventory or stock management, e.g. order filling, procurement or balancing against orders

Abstract

The present invention relates to technical field of the computer network more particularly to a kind of method and apparatus for automatically generating configuration file.A kind of method for automatically generating configuration file includes:Download configuration file template;The profile template is handled, obtains required configuration file.The present invention may be such that more warehouse distributed deployments of same application only need to configure a profile template, the configuration in dynamic generation difference warehouse, cost of labor is reduced, and then, it effectively solves the problems, such as prior art manual modification inefficiency and is not suitable for distributed deployment.

Description

A kind of method and apparatus for automatically generating configuration file
Technical field
The present invention relates to technical field of the computer network more particularly to a kind of methods and dress for automatically generating configuration file It puts.
Background technology
Warehousing system distributed deployment increases a warehouse newly and is required for disposing a whole set of application, such as outbound enters in warehouse Library checks, picks up goods etc..The deployment process of these applications is very complicated, and professional is needed to do the works such as a large amount of deployment, modification configuration Make.Newly open a warehouse every time, it is necessary to which operation maintenance personnel to carry out the modification of configuration file to application accordingly, such as change number It connects and goes here and there according to library, modification journal file path, modification domain name etc., although modification can be with meet demand, due to being hand by hand Dynamic modification, not only labor intensive, and intricate operation, inefficiency, error probability are big.
Mesh is all based on example to be configured for the automatic configuration of application:Create an application example;Extraction should answer Configuration file, and corresponding content is configured;By Distributor, the file distribution being configured to client End, then configuration synchronously complete.During extracting and configuration file is configured, manual modification can be related to, and configuration file is not Dynamic generates.The prior art is managed configuration file by example, is then issued to client again, is applied to storage system There are following several defects in system:Because warehouse is distributed deployment, the function of application example is identical, but its configuration file Content it is different, the prior art is difficult to meet to apply more deployed environments, the different demand of configuration file;It is existing in warehouse environment There is technical solution each warehouse can only be created an example, configuration file is then created in each example, is not released It puts human cost and improves efficiency;Poor user experience, a small amount of warehouse applications multioperation is configured can solve the problems, such as several times, still If warehouse quantity is just certain to cause waste of time, the waste of human cost, efficiency after tens or up to a hundred Lowly.
Invention content
In view of this, the present invention provides a kind of method and apparatus for automatically generating configuration file, can reduce manual intervention, It reduces cost of labor, reduce cumbersome labour, and working efficiency can be improved, and can reduce by more parts of configuration files and safeguard Cost, so as to reduce error probability.Therefore, the present invention solve in the prior art obtain configuration file be need manual intervention and The problem of cannot automatically generating.
To achieve the above object, according to an aspect of the invention, there is provided a kind of method for automatically generating configuration file.
The method of the present invention includes:Download configuration file template;The profile template is handled, obtains required configuration File.
Optionally, the profile template is handled to include:Handle the if functions in the profile template;Processing institute State for functions in profile template;The correlated variables in the profile template is substituted with the attribute of storehouse.
Optionally, this method further includes:According to the content creating profile template of the required configuration file of application;And Judge whether to need to generate more parts of configuration files, if so, be relative path by the path dynamic creation of profile template, Otherwise directly it is created as relative path;And if for letters are used in the presence of the content for needing to repeat in the profile template Number is handled;If there is the content for needing to judge in the profile template, handled using if functions.
Optionally, this method further includes:The profile template is stored in file server;And
Configuration file needed for being obtained by application programming interface, and will be right in configuration file write-in client The file answered.
Optionally, include but is not limited to using the content of required configuration file:The information and number of data-base cluster, The information in warehouse, application configuration information.
According to another aspect of the present invention, a kind of device for automatically generating configuration file is provided.
The system of the present invention includes:Download module, the download module are used for download configuration file template;And processing mould Block, the processing module is for handling the profile template, to obtain required configuration file.
Optionally, the processing module is additionally operable to:Handle the if functions in the profile template;Handle the configuration For functions in file template;The correlated variables in the profile template is substituted with the attribute of storehouse.
Optionally, which further includes creation module, for being configured according to the content creating of the required configuration file of application File template;And judge whether to need to generate more parts of configuration files, if so, the path of profile template is dynamically created It builds as relative path, is otherwise directly created as relative path;And if in the profile template exist need duplicate contents, It is handled using for functions;If there is the content for needing to judge in the profile template, at if functions Reason.
Optionally, which further includes memory module, for profile template to be stored in file server;It obtains Module for obtaining required configuration file by application programming interface, and the configuration file is written in client Corresponding file.
Optionally, include but is not limited to using the content of required configuration file:The information and number of data-base cluster, The information in warehouse, application configuration information.
According to the technique and scheme of the present invention, by download configuration file template, and profile template is handled, into And obtain required configuration file, i.e., the configuration of different path different contents can be generated using same profile template File.For identical application, when distributed deployment is to different warehouse configuration files, only download configuration file template, and Profile template can be automatically processed, effectively solve prior art manual modification inefficiency and is not suitable for distribution The problem of deployment.
Description of the drawings
Attached drawing does not form inappropriate limitation of the present invention for more fully understanding the present invention.Wherein:
Fig. 1 is a kind of schematic diagram of method key step for automatically generating configuration file according to embodiments of the present invention;
Fig. 2 is a kind of method flow diagram for automatically generating configuration file according to embodiments of the present invention;
Fig. 3 is a kind of schematic diagram of the main modular of device for automatically generating configuration file according to embodiments of the present invention.
Specific embodiment
It explains below in conjunction with attached drawing to the exemplary embodiment of the present invention, including the various of the embodiment of the present invention Details should think them only exemplary to help understanding.Therefore, those of ordinary skill in the art should recognize It arrives, various changes and modifications can be made to the embodiments described herein, without departing from scope and spirit of the present invention.Together For clarity and conciseness, the description to known function and structure is omitted in sample in following description.
Fig. 1 is a kind of schematic diagram of method key step for automatically generating configuration file according to embodiments of the present invention.
As shown in Figure 1, a kind of key step of method for automatically generating configuration file of the embodiment of the present invention includes:
S11:Download configuration file template.According to the content creating profile template of the required configuration file of application, and The profile template created is uploaded in file server and is stored.Wherein, using in required configuration file Appearance includes but is not limited to:The information and number of data-base cluster, the information in warehouse, application configuration information.
In embodiments of the present invention, template file is by the number and information of data-base cluster, the information in warehouse, application configuration The compositions such as information.Wherein, data-base cluster information:Storage facility located at processing plant and the configuration information of form library storage in warehouse, such as:IP, port are used Name in an account book, password etc..Warehouse information:The buffer address such as the web addresses in warehouse, redis, load balancing configuration etc..Application configuration Information:Include the daily record of application, connection pool, bean configurations etc..
During above-mentioned establishment profile template, judge whether to need to generate more parts of configuration files, if so, will The path dynamic creation of profile template is relative path, such as/conf/canalclient/canalClient-@ {mysql}.properties.template;Otherwise relative path is directly created as, such as/conf/canalclient/ redis.properties.template.And if there is the content that needs repeat in profile template, use for letters Number is handled, such as@{ fn:For (i, mysql) } xxxxx=xxxxx@{ fn:end}.The application for having some special needs root It is generated according to the quantity of data-base cluster there are the different configuration file in part variation, path, thus needs dynamic creation, it is non-dynamic State path is directly to write relative path exactly, is then directly created.
If being managed by example to configuration file, for the content that needs repeat, manual operations is needed, and the present invention is real It applies in example and is automatically processed using for functions, realization of being more convenient for automatically generates configuration file.If exist in profile template The content judged is needed, then is handled, i.e., is handled by following formula using if functions:
$if()$
Xxxx=xxxx
$else$
Xxxx=aaaa
$endif$。
S12:Profile template is handled, obtains required configuration file.Profile template processing uses StringTemplate template methods, the troublesome operation for reducing content by the way that for, if expression formula is configured and repeating configuration, promote work Make efficiency.StringTemplate is a template engine library (at present while support C#, Python, Ruby) based on Java, It can be used for generating the various formatted texts such as source code, Web page, Email.
Processing profile template includes:Handle the if functions in profile template;It handles in profile template For functions;With the correlated variables in the attribute alternative configuration file template of storehouse.From file server download configuration file template Afterwards, if accorded in profile template comprising $, the content between $ $ symbols is first handled, that is, handles if functions.Post processing for letters Number, and new context is generated, then handle the variable of storehouse environmental correclation.Finally, storehouse client can pass through application program Programming interface (API) obtains application configuration file content, and corresponding file is written.Wherein, the attribute particular content of storehouse with Content using required configuration file is corresponding, and in embodiments of the present invention, the attribute of storehouse includes the database IP in warehouse Wait the domain name, storehouse number and home-delivery center number, regional code etc. of basic informations and warehouse.
Fig. 2 is a kind of method flow diagram for automatically generating configuration file according to embodiments of the present invention.
As shown in Fig. 2, a kind of method for automatically generating configuration file of the embodiment of the present invention includes:
S21:Download configuration file template.The profile template created is stored in file server, in use, logical Cross file server download.
S22:Handle the if functions in profile template.If accorded with comprising $, the content between $ $ symbols is first handled, because The content of profile template is replaced by variable, so being needed before warehouse is issued to the change in template file Amount is replaced, and then can be just handed down to program and be used, between this symbol is exactly variable.In the embodiment of the present invention, if The judgement that function can carry out includes:Whether dynamic route is needed, judge warehouse type, judge whether to need in display portion file Hold.
S23:Handle for functions in profile template.It is different from prior art manual handle duplicate contents, the present invention Embodiment is automatically processed using for functions.There are repetition, fraction content difference in for functions processing profile template content Part, it is artificial only need to safeguard it is primary, it is possible to generate content according to specified quantity.
S24:With the correlated variables in the attribute alternative configuration file template of storehouse.With the attribute of storehouse, (warehouse environment becomes Amount:The key-value pair data generated according to warehouse information) correlated variables in profile template is replaced, be in operating process The key inside profile template is replaced with the attribute of storehouse.
S25:By above-mentioned processing, required configuration file is obtained.
S26:Configuration file needed for being obtained by application programming interface.
S27:Corresponding file is written, completes configuration process.
Fig. 3 is a kind of schematic diagram of the main modular of device for automatically generating configuration file according to embodiments of the present invention.
As shown in figure 3, a kind of device 3 for automatically generating configuration file of the embodiment of the present invention mainly includes:Download module 31 and processing module 32.Download module 31 is used for download configuration file template, and processing module 32 is used to handle the configuration file Template, to obtain required configuration file.
Processing module 32 is additionally operable to the if functions in processing profile template, and existing in the profile template of establishment needs The content to be judged is handled in profile template using if functions, when using profile template, need to be to if functions at Reason then if accorded with comprising $, first handles the content between $ $ symbols.In addition, processing module 32 is additionally operable in processing profile template For functions, the content for having repetition, fraction content different in profile template is handled.Also, processing module 32 use the correlated variables in the attribute alternative configuration file template of storehouse.Wherein, the particular content of the attribute of storehouse is with applying institute The content of the configuration file needed is corresponding, and in embodiments of the present invention, the attribute of storehouse includes the bases such as the database IP in warehouse The information and domain name in warehouse, storehouse number and home-delivery center number, regional code etc..
A kind of device 3 for automatically generating configuration file of the embodiment of the present invention further includes creation module, for according to application The content creating profile template of required configuration file automatically generates the device of configuration file;And judge whether to need More parts of configuration files are generated, if so, being relative path by the path dynamic creation of profile template, are otherwise directly created For relative path;If it and is handled in profile template in the presence of duplicate contents are needed using for functions;If configuration text There is the content for needing to judge in part template, handled using if functions.The processing of profile template uses StringTemplate template methods, the troublesome operation for reducing content by the way that for, if expression formula is configured and repeating configuration, promote work Make efficiency.
In addition, a kind of device 3 for automatically generating configuration file of the embodiment of the present invention further includes memory module and obtains mould Block.Memory module is used to profile template being stored in file server;Acquisition module is used to pass through application programming Interface obtains required configuration file, and configuration file is written corresponding file in client.Creation module is by configuration file Template, which creates, to be completed, and is stored in file server by memory module, wherein, for more warehouse distributed deployments of same application A profile template is only needed to configure, it, can dynamic generation difference storehouse later by the processing of download module and processing module The configuration file in library, it is possible to reduce manual intervention reduces cost of labor, reduces cumbersome labour, and then improve working efficiency.And And it reduces by more parts of configuration file maintenance costs and reduces error probability.
Above-mentioned specific embodiment, does not form limiting the scope of the invention.Those skilled in the art should be bright It is white, depending on design requirement and other factors, various modifications, combination, sub-portfolio and replacement can occur.It is any Modifications, equivalent substitutions and improvements made within the spirit and principles in the present invention etc., should be included in the scope of the present invention Within.

Claims (10)

  1. A kind of 1. method for automatically generating configuration file, which is characterized in that including:
    Download configuration file template;
    The profile template is handled, obtains required configuration file.
  2. 2. according to the method described in claim 1, include it is characterized in that, handling the profile template:
    Handle the if functions in the profile template;
    Handle for functions in the profile template;
    The correlated variables in the profile template is substituted with the attribute of storehouse.
  3. 3. it according to the method described in claim 1, it is characterized in that, further includes:
    According to the content creating profile template of the required configuration file of application;And
    Judge whether to need to generate more parts of configuration files, if so, being opposite by the path dynamic creation of profile template Otherwise path is directly created as relative path;And
    If there is the content for needing to repeat in the profile template, handled using for functions;If the configuration text There is the content for needing to judge in part template, then handled using if functions.
  4. 4. it according to the method described in claim 1, it is characterized in that, further includes:
    The profile template is stored in file server;And
    Configuration file needed for being obtained by application programming interface, and will be corresponding in configuration file write-in client File.
  5. 5. according to the method described in claim 3, it is characterized in that, include using the content of required configuration file but do not limit to In:The information and number of data-base cluster, the information in warehouse, application configuration information.
  6. 6. a kind of device for automatically generating configuration file, which is characterized in that including:
    Download module, the download module are used for download configuration file template;And
    Processing module, the processing module is for handling the profile template, to obtain required configuration file.
  7. 7. device according to claim 6, which is characterized in that the processing module is additionally operable to:
    Handle the if functions in the profile template;
    Handle for functions in the profile template;
    The correlated variables in the profile template is substituted with the attribute of storehouse.
  8. 8. device according to claim 6, which is characterized in that creation module is further included, for matching according to application is required Put the content creating profile template of file;And
    Judge whether to need to generate more parts of configuration files, if so, being opposite by the path dynamic creation of profile template Otherwise path is directly created as relative path;And
    If existing in the profile template needs duplicate contents, handled using for functions;If the configuration file mould There is the content for needing to judge in plate, handled using if functions.
  9. 9. device according to claim 6, which is characterized in that further include:
    Memory module, for profile template to be stored in file server;And
    Acquisition module for obtaining required configuration file by application programming interface, and the configuration file is written Corresponding file in client.
  10. 10. device according to claim 8, which is characterized in that the content of the required configuration file of application includes but not office It is limited to:The information and number of data-base cluster, the information in warehouse, application configuration information.
CN201611159481.6A 2016-12-15 2016-12-15 Method and device for automatically generating configuration file Active CN108228268B (en)

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 true CN108228268A (en) 2018-06-29
CN108228268B 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)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110795142A (en) * 2019-10-18 2020-02-14 郑州阿帕斯科技有限公司 Configuration file generation method and device
CN110889656A (en) * 2018-09-11 2020-03-17 北京京东振世信息技术有限公司 Warehouse rule configuration method and device
CN111159162A (en) * 2019-12-31 2020-05-15 中国联合网络通信集团有限公司 Database configuration method and device
CN112288344A (en) * 2019-07-24 2021-01-29 北京京东乾石科技有限公司 Scheduling task data processing method, device, equipment and storage medium
CN113055502A (en) * 2021-02-08 2021-06-29 中国电子科技集团公司第十五研究所 Automatic domain name registration method suitable for private cloud

Citations (5)

* Cited by examiner, † Cited by third party
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
CN104468148A (en) * 2013-09-12 2015-03-25 中兴通讯股份有限公司 Nginx server configuration maintenance method and system
US20150095473A1 (en) * 2013-09-30 2015-04-02 Oracle International Corporation Automatic configuration of applications based on host metadata using application-specific templates

Patent Citations (5)

* Cited by examiner, † Cited by third party
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
CN104468148A (en) * 2013-09-12 2015-03-25 中兴通讯股份有限公司 Nginx server configuration maintenance method and system
US20150095473A1 (en) * 2013-09-30 2015-04-02 Oracle International Corporation Automatic configuration of applications based on host metadata using application-specific templates
CN103530135A (en) * 2013-10-31 2014-01-22 深圳中兴网信科技有限公司 Proxy service generating device and proxy service generating method

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110889656A (en) * 2018-09-11 2020-03-17 北京京东振世信息技术有限公司 Warehouse rule configuration method and device
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
CN110795142A (en) * 2019-10-18 2020-02-14 郑州阿帕斯科技有限公司 Configuration file generation method and device
CN110795142B (en) * 2019-10-18 2023-04-07 郑州阿帕斯科技有限公司 Configuration file generation method and device
CN111159162A (en) * 2019-12-31 2020-05-15 中国联合网络通信集团有限公司 Database configuration method and device
CN113055502A (en) * 2021-02-08 2021-06-29 中国电子科技集团公司第十五研究所 Automatic domain name registration method suitable for private cloud
CN113055502B (en) * 2021-02-08 2022-07-29 中国电子科技集团公司第十五研究所 Automatic domain name registration method suitable for private cloud

Also Published As

Publication number Publication date
CN108228268B (en) 2021-11-12

Similar Documents

Publication Publication Date Title
CN108228268A (en) A kind of method and apparatus for automatically generating configuration file
US11269660B2 (en) Methods and systems for integrated development environment editor support with a single code base
CN106843837A (en) The construction method of openstack assembly containers
CN103177329B (en) Rule-based determination and checking in business object processing
US20130179858A1 (en) Framework for automated testing of mobile apps
CN104461567B (en) The dissemination method and system of software package
US20070256056A1 (en) Tool for automated extraction and loading of configuration settings
CN105786474A (en) Multi-tenant-supporting collaborative business flow customizing system and method
CN104503955A (en) Method for generating personalized excel form
CN109447406A (en) A kind of method of visioning procedure and the device of visioning procedure
CN103903086A (en) Method and system for developing management information system based on service model driving
CN108073390A (en) It is managed collectively the method, apparatus and system of configuration file in multiple engineerings
CN104881343A (en) Testing method and testing system
CN106202006A (en) Document generating method and device
CN110471754A (en) Method for exhibiting data, device, equipment and storage medium in job scheduling
CN105808748A (en) MIB (Management Information Base) version contrast method and device
CN106599244B (en) General original log cleaning device and method
CN109725927A (en) Synchronous method and device, the storage medium and terminal of code management system
CN109117431A (en) System and method for the source data applied from source to be incorporated into the target data of target application
CN102521133A (en) TCL (tool command language)-based white-box testing automation method and TCL-based white-box testing automation system
CN103902676A (en) Bill extension item user-defining device and method
AU2018313995B2 (en) Systems and methods for providing globalization features in a service management application interface
PAULA et al. Fordism, post-fordism, and cyberfordism: the paths and detours of Industry 4.0
US11750458B1 (en) Structured network change controls
CN113779003B (en) Information processing method and device

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