CN108664270A - Environment dynamic switching method, device, computer equipment and storage medium - Google Patents
Environment dynamic switching method, device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN108664270A CN108664270A CN201810435800.4A CN201810435800A CN108664270A CN 108664270 A CN108664270 A CN 108664270A CN 201810435800 A CN201810435800 A CN 201810435800A CN 108664270 A CN108664270 A CN 108664270A
- Authority
- CN
- China
- Prior art keywords
- environment
- macrodefinition
- target
- optional
- switch
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 39
- 238000003860 storage Methods 0.000 title claims abstract description 20
- 230000007613 environmental effect Effects 0.000 claims description 53
- 230000004913 activation Effects 0.000 claims description 15
- 238000004590 computer program Methods 0.000 claims description 13
- 238000012545 processing Methods 0.000 claims description 7
- 238000012360 testing method Methods 0.000 description 27
- 238000011161 development Methods 0.000 description 16
- 238000004519 manufacturing process Methods 0.000 description 13
- 230000006870 function Effects 0.000 description 7
- 238000010586 diagram Methods 0.000 description 6
- 230000008569 process Effects 0.000 description 4
- 238000004364 calculation method Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 241000208340 Araliaceae Species 0.000 description 1
- 235000005035 Panax pseudoginseng ssp. pseudoginseng Nutrition 0.000 description 1
- 235000003140 Panax quinquefolius Nutrition 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 230000010485 coping Effects 0.000 description 1
- 238000005520 cutting process Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 238000009826 distribution Methods 0.000 description 1
- 238000007667 floating Methods 0.000 description 1
- 235000008434 ginseng Nutrition 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000037361 pathway Effects 0.000 description 1
- 238000002360 preparation method Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/76—Adapting program code to run in a different environment; Porting
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Stored Programmes (AREA)
Abstract
The invention discloses a kind of environment dynamic switching method, device, computer equipment and storage mediums.This approach includes the following steps:It configures the configuration parameter of at least two optional environment, obtains macrodefinition switch corresponding with each optional environment;Environment changing request is obtained, the environment changing request includes target environment mark;It is identified based on the target environment, target macrodefinition switch corresponding with target environment mark is obtained in macrodefinition switch;It is switched based on the target macrodefinition, target configuration parameter corresponding with the target macrodefinition switch is obtained in the configuration parameter, the target environment is switched to according to the target configuration parameter.It is realized through the invention without relying on network real time environment switching at runtime.
Description
Technical field
The present invention relates to field of communication technology more particularly to a kind of environment dynamic switching method, device, computer equipment and
Storage medium.
Background technology
Software development links, each link such as generally comprises exploitation, tests and reach the standard grade and corresponds to a kind of environment, that is, be corresponding with out
Hair ring border, test environment and upper thread environment.In software development, partial code is only run in exploitation or test, is being reached the standard grade
Shi Buneng is run, such as the code of the mock data of test, automated log on to facilitate debugging to apply.Current software development process
In, it needs to toggle between varying environment, to carry out software scheduling.Current generally use the following two kinds method realization pair
Environment changing:First, realize that environment changing, this mode need to rely on network environment by server configuration mode, network environment compared with
In the case of difference, switching cannot achieve;It comes into force second is that this switches the when of restarting next time, this mode can not carry out dynamically cutting in real time
It changes.
Invention content
A kind of environment dynamic switching method of offer of the embodiment of the present invention, device, computer equipment and storage medium, to solve
The problem of current environment cannot achieve real-time switching at runtime when switching.
A kind of environment dynamic switching method, including:
It configures the configuration parameter of at least two optional environment, obtains macrodefinition corresponding with each optional environment and open
It closes;
Environment changing request is obtained, the environment changing request includes target environment mark;
It is identified based on the target environment, mesh corresponding with target environment mark is obtained in macrodefinition switch
Mark macrodefinition switch;
It is switched, is obtained in the configuration parameter corresponding with the target macrodefinition switch based on the target macrodefinition
Target configuration parameter switches to target environment according to the target configuration parameter.
A kind of environment dynamic switching device, including:
Parameter configuration module, for configure the configuration parameters of at least two optional environment, obtain and it is each it is described can ring selection
The corresponding macrodefinition switch in border;
Switching request acquisition module, for obtaining environment changing request, the environment changing request includes target environment mark
Know;
Macrodefinition switch acquisition module, for based on the target environment identify, the macrodefinition switch in obtain with
The target environment identifies corresponding target macrodefinition switch;
Environment changing processing module, for being switched based on the target macrodefinition, acquisition and institute in the configuration parameter
It states target macrodefinition and switchs corresponding target configuration parameter, target environment is switched to according to the target configuration parameter.
A kind of computer equipment, including memory, processor and be stored in the memory and can be in the processing
The computer program run on device, the processor realize above-mentioned environment dynamic switching method when executing the computer program
Step.
A kind of computer readable storage medium, the computer-readable recording medium storage have computer program, the meter
The step of calculation machine program realizes above-mentioned environment dynamic switching method when being executed by processor.
Above-mentioned environment dynamic switching method, device, computer equipment and storage medium, can ring selection by configuring at least two
The configuration parameter in border, each optional environment correspond to macrodefinition switch, can realize that environment is switched fast by macrodefinition switch;
Corresponding target macrodefinition switch is obtained according to the target environment mark in the environment changing request received, target macrodefinition is opened
Close the configuration parameter of a corresponding optional environment realizes environment according to the configuration parameter switching of an optional environment to target environment
Switching at runtime can be related to switching at runtime switch efficiency with significant increase, not depend on network limitation, and can come into force in real time, promotion is opened
Concern changes experience.
Description of the drawings
In order to illustrate the technical solution of the embodiments of the present invention more clearly, below by institute in the description to the embodiment of the present invention
Attached drawing to be used is needed to be briefly described, it should be apparent that, the accompanying drawings in the following description is only some implementations of the present invention
Example, for those of ordinary skill in the art, without having to pay creative labor, can also be according to these attached drawings
Obtain other attached drawings.
Fig. 1 is a flow chart of environment dynamic switching method in one embodiment of the invention;
Fig. 2 is a particular flow sheet of step S10 in one embodiment of the invention;
Fig. 3 is a particular flow sheet of step S20 in one embodiment of the invention;
Fig. 4 is a schematic diagram of environment dynamic switching method in one embodiment of the invention;
Fig. 5 is a schematic diagram of environment dynamic switching device in one embodiment of the invention;
Fig. 6 is a schematic diagram of one embodiment of the invention Computer equipment.
Specific implementation mode
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation describes, it is clear that described embodiments are some of the embodiments of the present invention, instead of all the embodiments.Based on this hair
Embodiment in bright, the every other implementation that those of ordinary skill in the art are obtained without creative efforts
Example, shall fall within the protection scope of the present invention.
Fig. 1 shows the flow chart of environment dynamic switching method in one embodiment of the invention.The environment dynamic switching method is answered
It is quick in the computer equipment for carrying out software development, being used to carry out the corresponding environment of the links of software development
Switching at runtime needs not rely upon network environment.The computer equipment includes but not limited to the equipment such as computer and server, this implementation
It is illustrated by taking server as an example in example.As shown in Figure 1, the environment dynamic switching method includes the following steps:
S10:It configures the configuration parameter of at least two optional environment, obtains macrodefinition corresponding with each optional environment and open
It closes.
Wherein, optional environment is for developer, refers to multiple publications and server in operating status, including
Issue environment, development environment and test environment etc..The configuration parameter of optional environment refers to that preconfigured can access can ring selection
The parameter in border, the configuration parameter include IP (Internet Protocol, the agreement interconnected between network) and port numbers, so as to
In being subsequently based on the configuration parameter access optional environment accordingly.
Wherein, when configuring the configuration parameter of optional environment, it should be noted that join the configuration of at least two optional environment
Number is configured.The configuration parameter of each optional environment is made of some projects file, and item file includes but not limited to head text
Part and definition file etc..Wherein, header file refers to the file of the statement (declaration) for save routine.Wherein, IP and
Port numbers are stated in header file.Wherein, it is the realization (implementation) for save routine to define file
File.Wherein, the environmental labels of each optional environment and macrodefinition switch are stated in header file, by each optional environment
Environmental labels, macrodefinition switch and configuration parameter establish incidence relation, by incidence relation, according to the environment mark of optional environment
Knowledge can find the corresponding macrodefinition switch of optional environment, can be at least two according to the corresponding macrodefinition switch of optional environment
The configuration parameter of optional environment is found in the configuration parameter of a optional environment.
Specifically, the configuration parameter of at least two optional environment of configuration specifically refers to configure at least two in same server
The configuration parameter of optional environment, optional environment can be specifically development environment, test environment and running environment etc., configure in parameter
Including IP and port numbers.The configuration parameter of each optional environment is different, specifically configures IP and port numbers difference in parameter.Example
Such as, configure the corresponding development environment of server of any APP (Application, application program) or website, test environment and
The configuration parameter of the optional environment such as running environment so that the corresponding IP of each optional environment and port numbers differ, to be based on
Corresponding configuration parameter is from an optional environment changing to another optional environment.I.e. the configuration parameter based on optional environment can realize from
Development environment switches to test environment or running environment, especially by the IP and port numbers in the configuration parameter of each optional environment
Realize the switching of optional environment.
Macrodefinition refers to that also known as macro-micro relations, macro substitution, basic format are:#define identifier characters.Macrodefinition is opened
Pass refers to defining optional environment by macrodefinition format, specifically separates some and particular header file using #ifdef indicators
(macrodefinition i.e. in the present embodiment), program library and the related code of alternative document version, basic format are:
#ifdef sentences 1
Program 2
#endif
Above-mentioned basic format is particularly applicable under following scene:Macrodefinition sentence 1 then executes program 2.
It configures the configuration parameter of at least two optional environment and will provide each optional environment corresponding macrodefinition switch, it can
To be interpreted as:The configuration parameter of optional environment is distinguished by macrodefinition.For example, the matching optional environment using macrodefinition
Parameter is set to distinguish:
#ifdef macrodefinitions execute conditional statement
The configuration parameter of the optional environment of the #define SOCKET_IP_PORT " " // configuration parameter can be IP and port
Number
#else
In above-mentioned example, when macrodefinition executes conditional statement triggering, (i.e. #define is switched based on macrodefinition
The configuration parameter of the optional environment of SOCKET_IP_PORT@" ") in configuration parameter realize that environment changing, each macrodefinition switch are logical
Its configuration parameter is crossed to distinguish.
In this step, by configuring the configuration parameter of at least two optional environment, and it is corresponding to provide each optional environment
Macrodefinition switchs, and macrodefinition switch is associated with the configuration parameter of optional environment, can pass through macrodefinition based on an optional environment
Corresponding configuration parameter switching is switched to another optional environment.
Fig. 2 shows a flow charts of step S10 in one embodiment of the invention, as shown in Fig. 2, in step S10, configuration is at least
The configuration parameter of two optional environment, obtains macrodefinition corresponding with each optional environment and switchs and specifically comprise the following steps:
S11:At least two optional environment are connected to same server in advance, obtain server info.
Wherein, server info refers to the configuration parameter of optional environment division, and server info includes the Web clothes of website
Business device, script resolver version, IP, content of text type, website domain name, type of server and website physical pathway etc..Specifically
Ground obtains the server info of each optional environment, passes through clothes by the way that at least two optional environment are connected to same server
Device information of being engaged in carries out page access.
S12:The configuration parameter of optional environment is obtained, configuration parameter includes IP and port numbers.
Wherein, configuration parameter includes but not limited to IP and port numbers etc..
In the present embodiment, the configuration parameter under each optional environment of dynamic access, each optional environment under same server
The IP and port numbers difference in parameter are configured, to connect corresponding optional environment with port numbers according to IP.Wherein in macrodefinition
Parameter can be defined as follows [[GlobalVariables shareGlobalVariabl es] serverIP], which is
Become the format of ginseng macrodefinition.
S13:The identifier of macrodefinition is determined based on server info, and using IP and port numbers as the character of macrodefinition
String is switched with obtaining macrodefinition corresponding with optional environment.
Wherein, macrodefinition basic format is:#define identifier character strings are determined macro by the server info of acquisition
The identifier of definition.For example, IP_PORT to be set as to the identifier of macrodefinition, using IP and port numbers in configuration parameter as macro
The character string of definition.
Specifically, page access is carried out by server info, the website domain name of page access part will be carried out as macro
The identifier of definition before program is compiled, will be identified using IP in server info and port numbers as the character string of macrodefinition
Symbol replaces with character string, is compiled to character string.In the present embodiment, domain name is for identifying each environment server, for example, exploitation
Environment server, test environment service device and running environment server etc..
For example, in macrodefinition in #define SOCKET_IP_PORT@" 192.XXX.XX.81 ", SO CKET_IP_PORT
For the identifier of macrodefinition switch ,@" 192.XXX.XX.81 " is the character string of macrodefinition switch, and wherein X is number, when compiling,
SOCKET_IP_PORT is replaced with into@" 192.XXX.XX.81.
In another example #define SOCKET_HTTP_URL@" http://192.XXX.XX.81:5320/han dler/
In requestAddress ", SOCKET_HTTP_URL is the identifier of macrodefinition switch ,@" htt p://
192.XXX.XX.81:5320/handler/requestAddress " is the character string of macrodefinition switch.
In step S11-S13, parameter by the server info of the optional environment of acquisition and is configured by macrodefinition format, with
The corresponding macrodefinition switch of optional environment is obtained, configuration process is simple and fast, helps to realize the quick reality of environment switching at runtime
Row.
Wherein, in the configuration parameter for configuring at least two optional environment, macrodefinition corresponding with each optional environment is obtained
After the step of switch (i.e. step S10), which further includes:Obtain the optional environment mark of optional environment
Know, and optional environmental labels and macrodefinition are switched into associated storage to local file.Specifically, each optional environment of definition corresponds to
Optional environmental labels, and optional environmental labels and macrodefinition switch are associated, and incidence relation are stored to local text
Part.For example, optional environment is development environment, test environment and running environment, development environment can be identified and be set as 1, by test wrapper
Border mark is set as 2, running environment mark is set as 3, and the macrodefinition for providing development environment, test environment and running environment is opened
It closes, the mark 1 of development environment is associated with the switch setting of the macrodefinition of development environment, by the mark 2 and test wrapper of test environment
The mark 3 of running environment is associated with the switch setting of the macrodefinition of running environment, and will close by the macrodefinition switch setting association in border
Connection relationship is stored to local file.It is to be appreciated that by optional environmental labels and corresponding macrodefinition switch associated storage at this
In ground file, be conducive to subsequently find corresponding macrodefinition switch from local file based on optional environmental labels.
S20:Environment changing request is obtained, environment changing request includes target environment mark.
Wherein, environment changing request is the request for asking progress environment changing, and target environment refers to that current needs are cut
The optional environment shifted to.Target environment mark refers to the corresponding mark of target environment.Due to each optional environment in local file
Corresponding macrodefinition switch associated storage is identified, and target environment belongs to one in optional environment, can be based on target ring
Border identifier lookup is switched to corresponding macrodefinition.
Specifically, it when getting environment changing request, needs that first environment changing request is identified, wherein different
Environment changing request transmit different parameters, the parameter transmitted includes target environment mark in environment changing request.Server
Obtain environment changing request after, in define file to environment changing ask in transmit target environment mark be identified with
Assert.
Fig. 3 shows a flow chart of step S20 in one embodiment of the invention, as shown in figure 3, in step S20, obtains environment
Switching request, environment changing request include target environment mark, including:
S21:Show that at least two optional environmental informations, each optional environmental information include switch on environment changing interface
State.
Specifically, it is multiple regions by environment changing boundary division according at least two optional environment differences of configuration, often
The corresponding optional environmental information of one optional environment of display in the corresponding region of one optional environment, wherein optional environmental information includes
Optional environmental labels further include the on off state of the corresponding macrodefinition switch of optional environment, and on off state can be idle state
Or state of activation.Wherein, idle state refers to that optional environment is in unactivated state, and state of activation refers at optional environment
In the state of activation.Synchronization, at least two macrodefinitions can only be there are one being active in switching, other macrodefinitions are opened
Pass need to be in idle condition.The optional environmental information that user terminal is shown by the different region in environment changing interface, to environment into
Row switching, wherein environment changing interface highlights the current corresponding region of environment, and display switch state is sharp
Living, highlighting can specifically be shown by modes such as floating frame, font intensification and color burns, can for being different from other
Ring selection border, without highlighting, what is shown in the corresponding region of other optional environment opens in other optional environment corresponding region
Off status is idle state.Wherein, user terminal refers to corresponding with server, and the program of local service is provided for client.Pass through
This step, based on the optional environmental information shown in environment changing interface, so that user can be appreciated that current all optional environment pair
The on off state for the macrodefinition switch answered, in order to carry out selecting that environment can be switched by environment changing interface.
S22:Obtain the environment changing that user is inputted using any optional environmental information clicked on environment changing interface
Request.
Wherein, at least one optional environmental information is shown on environment changing interface, each optional environmental information corresponds to one can
Select environmental labels.When user is using any optional environmental information on environment changing interface is clicked, server can get with
The corresponding environment changing request of the optional environmental information clicked, at this point, environment changing request include user's click can
Select the corresponding target environment mark of environmental information.Specifically, environment changing request further includes the address parameter etc. of user terminal.Example
Such as, the optional environmental information such as environment changing interface display development environment, test environment and running environment, optional environmental information include
The mark 1 of development environment, the mark 2 of test environment and the mark 3 of running environment, moreover, environment changing interface also shows mark
1,2 and 3 corresponding on off state.When environment changing interface display current server environmental applications are when being identified as 1,1 pair is identified
The on off state answered is state of activation, and 2 and 3 corresponding on off states of mark are idle state, are sent at this point, can receive user terminal
Switch to mark 2 either 3 environment changing request environment changing request include identify 2 or 3.
Further, the environment changing that user is inputted using any optional environmental information clicked on environment changing interface
Request when user's selected environment switches optional environmental area on interface, is differently shown selected optional environmental area, uses
Family can click the corresponding region of the arbitrarily optional environment in environment changing interface, be switched to when receiving user in a manner of clicking
When another optional environment, server can receive environment switching request.It should be noted that when user selectes another optional environment
When, another optional environment is differently shown, in order to which user understands the environment of current selected.
Step S21-S22, by least two optional environmental information of environment changing interface display, wherein optional environment
Information includes on off state, according to the optional environmental information of environment changing interface display, to obtain server current application can
A certain environment in ring selection border, and show other optional environmental informations.By click on environment changing interface it is any can ring selection
Border information and input environment changing request, switch to other optional environment from current environment, handoff procedure is simple and convenient.
S30:It is identified based on target environment, target macrodefinition corresponding with target environment mark is obtained in macrodefinition switch
Switch.
Wherein, target macrodefinition switch refers to the corresponding macrodefinition switch of selected target environmental labels.
Specifically, it is identified according to selected target environment, in the corresponding macrodefinition switch of preconfigured optional environment
It obtains target environment and identifies corresponding macrodefinition switch.Wherein, the environmental labels of each optional environment, macrodefinition are opened in header file
It closes and configuration parameter is equipped with correspondence, by the correspondence of target environment mark and target macrodefinition switch, be based on target
Environmental labels get corresponding target macrodefinition switch.
Being identified based on target environment in step S30 obtains mesh corresponding with target environment mark in macrodefinition switch
Macrodefinition switch is marked, is specifically included:It is identified based on target environment and calls local file, to target environment mark in local file
The optional environmental labels of storage are matched, if successful match, are obtained in macrodefinition switch corresponding with target environment mark
Target macrodefinition switch.Wherein, the pass of optional environmental labels and the macrodefinition switch of optional environment is stored in local file
Target environment mark is used as canonical to match by connection relationship, by regular expression matching rule, is started in local file to knot
All contents of tail are matched with target environment mark, and in local file, a certain content is matched into target environment mark
Work(then returns to target environment mark, and obtains target environment mark in the corresponding macrodefinition switch of preconfigured optional environment
Know corresponding macrodefinition switch, and corresponding macrodefinition switch is switched as target macrodefinition.For example, target environment is identified as
It when 3, calls local file and is matched in local file, when the successful match in local file, obtain target environment
Mark 3 and corresponding macrodefinition switch are switched as target macrodefinition.
Further, after the step of macrodefinition switch corresponding with each optional environment is obtained in macrodefinition switch,
Environment dynamic switching method further includes:The on off state of default setting macrodefinition switch is idle state.Specifically, it configures at least
When the corresponding macrodefinition switch of two optional environment, set the on off state that the macrodefinition of at least two optional environment switchs to
Idle state, user can access the optional environment that any one macrodefinition switch is idle state.Wherein, the switch of macrodefinition switch
State can the on off state of environment default setting a certain macrodefinition switch according to demand be idle state, or environment according to demand
The on off state of a certain macrodefinition switch of default setting is state of activation, and the on off state of other macrodefinitions switch is set as idle
State.It is defaulted as idle state by the on off state for switching macrodefinition, target ring can be activated according to actual environmental demand
The on off state of the macrodefinition switch in border saves the time of environment changing with access target environment.
Further, it can select one of them can ring selection from least two optional environment according to the progress of software development
The macrodefinition on off state in border is set as state of activation, and when accessing server, the switch of macrodefinition switch can directly be accessed
State is the optional environment (being determined as default contexts) of state of activation, when needing to switch to optional environment from default contexts,
It needs to send environment changing request.For example, in one server of default setting development environment, test environment and running environment these three
In optional environment, the on off state of the macrodefinition switch of running environment is state of activation, and default access is run when accessing server
Environment needs to send environment changing request when needing to access development environment and test environment.Further, if user terminal is true
Determine server and be in an optional environment for a long time, sets the optional environment as default contexts, the default contexts are corresponding macro fixed
The on off state of justice switch is set as state of activation, so as to be cut automatically into default contexts with saving environment when server is switched on
Change the time.
Correspondingly, obtained in macrodefinition switch the step of corresponding with target environment mark target macrodefinition switchs it
Afterwards, environment dynamic switching method further includes:The on off state that target macrodefinition switchs is switched to state of activation.Specifically, root
Corresponding target macrodefinition switch is obtained according to target environment mark, the on off state that target macrodefinition switchs is switched to activation shape
The on off state of state, other optional environment is idle state.For example, when switching to development environment from running environment, obtain
The target macrodefinition of development environment switchs, and the target macrodefinition of development environment is switched to state of activation, other optional environment
On off state is idle state, to realize environment changing.
S40:It is switched based on target macrodefinition, target configuration corresponding with target macrodefinition switch is obtained in configuring parameter
Parameter switches to target environment according to target configuration parameter.
Wherein, target configuration parameter refers to the configuration parameter of target environment, passes through IP in target configuration parameter and port
Number switch to target environment.Specifically, the environmental labels of each optional environment, macrodefinition switch and configuration parameter are set in header file
There is correspondence, target is obtained in the configuration parameter of preconfigured at least two optional environment by target macrodefinition switch
Parameter is configured, IP and port numbers in target configuration parameter is read, target environment is switched to according to IP and port numbers.Therefore pass through mesh
Standard configuration sets parameter, switches to target environment, realizes the switching of environment dynamic realtime.In the present embodiment, target configuration parameter is advance
It has been configured that, each optional environment is configured by macrodefinition mode.
Fig. 4 is a schematic diagram of environment dynamic switching method in one embodiment of the invention.As shown in figure 4, environment dynamic
Switching method includes:First, the configuration parameter of optional environment is configured, that is, configures the configuration parameter of production environment and test environment,
And the macrodefinition switch of production environment and test environment is obtained, the macrodefinition switch of default test environment is identified as 1, produces ring
The macrodefinition switch in border is identified as 2.Then, Connection Service device obtains server info, and the page is carried out according to server info
It accesses, reads the online macrodefinition switch mark of dynamic, when the mark 1 for reading the corresponding macrodefinition switch of test environment, according to
Macrodefinition switch mark 1 obtains test environment macrodefinition switch, is switched based on test environment macrodefinition and obtains matching for test environment
Parameter is set, according to the configuration parameter Connection Service device of test environment, and is accessed under the test environment.When user need to be by environment
Production environment is switched to, the macrodefinition that production environment is clicked from environment changing interface switchs corresponding environmental information, environmental information
On off state including production environment and mark.Specifically, production environment corresponds to the mark in environmental information region when the user clicks
2, click production environment macrodefinition switch corresponding environmental information before, correspond to viewing area in environment changing interface detection environment
Domain highlights, and clicks the mark 2 of production environment corresponding region, and macrodefinition switch mark is changed to 2 from 1, reads macrodefinition
Switch mark 2 obtains production environment macrodefinition switch corresponding with macrodefinition switch mark 2, and is based on production environment macrodefinition
Switch obtain production environment configuration parameter, according to the configuration parameter Connection Service device of production environment, and in a production environment into
Row accesses, and realizes environment switching at runtime, does not depend on network limitation, and can come into force in real time.
In the environment dynamic switching method that the present embodiment is provided, the configuration by configuring at least two optional environment is joined
Number, each optional environment correspond to macrodefinition switch, can realize that environment is switched fast, and passes through reception ring by macrodefinition switch
Border switching request switches over environment;Corresponding mesh is obtained according to the target environment mark in the environment changing request received
Mark macrodefinition switch, wherein the configuration parameter of the corresponding optional environment of target macrodefinition switch, according to the configuration of an optional environment
Parameter switching realizes environment switching at runtime to target environment, and switching at runtime switch efficiency can be related to significant increase, is not depended on
Network limits, and can come into force in real time, lifting switch switching experience.
It should be understood that the size of the serial number of each step is not meant that the order of the execution order in above-described embodiment, each process
Execution sequence should be determined by its function and internal logic, the implementation process without coping with the embodiment of the present invention constitutes any limit
It is fixed.
Fig. 5 is a functional block diagram of environment dynamic switching device in one embodiment of the invention.The environment dynamic switching device
It is corresponded with environment dynamic switching method in above-described embodiment.As shown in figure 5, the environment dynamic switching device includes that parameter is matched
Set module 10, switching request acquisition module 20, macrodefinition switch acquisition module 30 and environment changing processing module 40.Wherein, join
The reality of number configuration module 10, switching request acquisition module 20, macrodefinition switch acquisition module 30 and environment changing processing module 40
Existing function step one-to-one correspondence corresponding with environment dynamic switching method in embodiment 1, to avoid repeating, the present embodiment is not one by one
It is described in detail.
Parameter configuration module 10, the configuration parameter for configuring at least two optional environment obtain and each optional environment
Corresponding macrodefinition switch.
Switching request acquisition module 20, for obtaining environment changing request, environment changing request includes target environment mark.
Macrodefinition switchs acquisition module 30, for being identified based on target environment, is obtained and target ring in macrodefinition switch
Border identifies corresponding target macrodefinition switch.
Environment changing processing module 40, for being switched based on target macrodefinition, it is fixed with target macro to be obtained in configuring parameter
Justice switchs corresponding target configuration parameter, and target environment is switched to according to target configuration parameter.
Preferably, parameter configuration module 10 includes server info acquiring unit 11, configuration parameter acquiring unit 12 and opens
Close acquiring unit 13.
Server info acquiring unit 11 is obtained at least two optional environment to be connected to same server in advance
Server info.
Parameter acquiring unit 12 is configured, the configuration parameter for obtaining optional environment, configuration parameter includes IP and port numbers.
Acquiring unit 13, the identifier for determining macrodefinition based on server info are switched, and IP and port numbers are made
For the character string of macrodefinition, switched with obtaining macrodefinition corresponding with optional environment.
Preferably, parameter configuration module 10 are additionally operable in the step for obtaining macrodefinition corresponding with each optional environment and switching
After rapid, the on off state of default setting macrodefinition switch is idle state.
Macrodefinition switchs acquisition module 30, is additionally operable to identify corresponding target macrodefinition switch with target environment in acquisition
After step, the on off state that target macrodefinition switchs is switched to state of activation.
Preferably, parameter configuration module 10 are additionally operable to, in the configuration parameter for configuring at least two optional environment, obtain and every
After the step of one optional environment corresponding macrodefinition switch, the optional environmental labels of optional environment are obtained, and by optional environment
Mark switchs associated storage to local file with macrodefinition.
Macrodefinition switchs acquisition module 30, for calling local file based on target environment mark, is identified to target environment
The optional environmental labels stored in local file are matched, if successful match, are obtained corresponding with target environment mark
Target macrodefinition switchs.
Preferably, switching request acquisition module 20 includes that optional environmental information display unit 21 and environment changing request receive
Unit 22.
Optional environmental information display unit 21, for showing at least two optional environmental informations on environment changing interface,
Each optional environmental information includes on off state.
Environment changing request reception unit 22, for obtain user using click on environment changing interface it is any can ring selection
Border information and input environment changing request.
In one embodiment, a computer readable storage medium is provided, meter is stored on the computer readable storage medium
Calculation machine program, the computer program realize environment dynamic switching method in above-described embodiment when being executed by processor, to avoid weight
Multiple, which is not described herein again.Alternatively, the computer program realizes that environment switching at runtime fills in above-described embodiment when being executed by processor
The function of each module/unit in setting, to avoid repeating, which is not described herein again.
It is to be appreciated that computer readable storage medium may include:Any reality of computer program code can be carried
Body or device, recording medium, USB flash disk, mobile hard disk, magnetic disc, CD, computer storage, read-only memory (ROM, Read-
Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal and telecommunication signal etc..
Fig. 6 is the schematic diagram for the computer equipment that one embodiment of the invention provides.As shown in fig. 6, the calculating of the embodiment
Machine equipment 60 includes:Processor 61, memory 62 and it is stored in the calculating that can be run in memory 62 and on processor 61
Machine program 63.The step of processor 61 realizes environment dynamic switching method in above-described embodiment when executing computer program 63, example
Step S10 to S40 as shown in Figure 1.Alternatively, processor 61 realizes that environment is dynamic in above-described embodiment when executing computer program 63
The function of each module/unit of state switching device, for example, it is parameter configuration module 10 shown in Fig. 5, switching request acquisition module 20, macro
The function of definition switch acquisition module 30 and environment changing processing module 40.
Wherein, computer equipment 60 can be that desktop PC, notebook, palm PC and cloud server etc. are set
Standby, Fig. 6 is only the example of the present embodiment Computer equipment, may include that such as Fig. 6 shows more or fewer components or group
Close certain components or different components.Memory 62 can be the internal storage unit of computer equipment, such as hard disk or memory,
Can also be the external memory unit of computer equipment, such as plug-in type hard disk, intelligent memory card (Smart Media Card,
SMC), secure digital (Secure Digital, SD) blocks, flash card (Flash Card) etc..Computer program 63 includes program
Code, the program code can be source code form, object identification code form, executable file or certain intermediate forms etc..
It is apparent to those skilled in the art that for convenience of description and succinctly, only with above-mentioned each work(
Can unit, module division progress for example, in practical application, can be as needed and by above-mentioned function distribution by different
Functional unit, module are completed, i.e., the internal structure of device are divided into different functional units or module, to complete above description
All or part of function.
The above embodiments are merely illustrative of the technical solutions of the present invention, rather than its limitations;Although with reference to the foregoing embodiments
Invention is explained in detail, it will be understood by those of ordinary skill in the art that:It still can be to aforementioned each implementation
Technical solution recorded in example is modified or equivalent replacement of some of the technical features;And these modification or
It replaces, the spirit and scope for various embodiments of the present invention technical solution that it does not separate the essence of the corresponding technical solution should all include
Within protection scope of the present invention.
Claims (10)
1. a kind of environment dynamic switching method, which is characterized in that including:
It configures the configuration parameter of at least two optional environment, obtains macrodefinition switch corresponding with each optional environment;
Environment changing request is obtained, the environment changing request includes target environment mark;
It is identified based on the target environment, target macro corresponding with target environment mark is obtained in macrodefinition switch
Definition switch;
It is switched based on the target macrodefinition, target corresponding with the target macrodefinition switch is obtained in the configuration parameter
Parameter is configured, target environment is switched to according to the target configuration parameter.
2. environment dynamic switching method as described in claim 1, which is characterized in that at least two optional environment of the configuration
Parameter is configured, macrodefinition switch corresponding with each optional environment is obtained, including:
At least two optional environment are connected to same server in advance, obtain server info;
The configuration parameter of the optional environment is obtained, the configuration parameter includes IP and port numbers;
The identifier of macrodefinition is determined based on the server info, and using the IP and port numbers as the character of macrodefinition
String, to obtain macrodefinition switch corresponding with the optional environment.
3. environment dynamic switching method as described in claim 1, which is characterized in that at least two optional environment of the configuration
Configuration parameter, after the step of obtaining macrodefinition switch corresponding with each optional environment, the environment switching at runtime
Method further includes:
The optional environmental labels of the optional environment are obtained, and the optional environmental labels are associated with the macrodefinition and are deposited
It stores up to local file;
It is described to be identified based on the target environment, obtain mesh corresponding with target environment mark in macrodefinition switch
Macrodefinition switch is marked, including:
It is identified based on target environment and calls local file, the target environment identified described in being stored in the local file
Optional environmental labels are matched, if successful match, are obtained in macrodefinition switch and target environment mark pair
The target macrodefinition switch answered.
4. environment dynamic switching method as described in claim 1, which is characterized in that it is described acquisition with it is each it is described can ring selection
After the step of corresponding macrodefinition in border switchs, the environment dynamic switching method further includes:
The on off state that macrodefinition described in default setting switchs is idle state;
It is described obtained in the macrodefinition switch the step of corresponding with target environment mark target macrodefinition switchs it
Afterwards, the environment dynamic switching method further includes:
The on off state that the target macrodefinition switchs is switched to state of activation.
5. environment dynamic switching method as described in claim 1, which is characterized in that the acquisition environment changing request, it is described
Environment changing request includes target environment mark, including:
Show that at least two optional environmental informations, each optional environmental information include switch shape on environment changing interface
State;
Obtain the environment changing that user is inputted using any optional environmental information clicked on the environment changing interface
Request.
6. a kind of environment dynamic switching device, which is characterized in that including:
Parameter configuration module, the configuration parameter for configuring at least two optional environment obtain and each optional environment pair
The macrodefinition switch answered;
Switching request acquisition module, for obtaining environment changing request, the environment changing request includes target environment mark;
Macrodefinition switch acquisition module, for based on the target environment identify, the macrodefinition switch in obtain with it is described
Target environment identifies corresponding target macrodefinition switch;
Environment changing processing module is obtained and the mesh for being switched based on the target macrodefinition in the configuration parameter
It marks macrodefinition and switchs corresponding target configuration parameter, target environment is switched to according to the target configuration parameter.
7. environment dynamic switching device as claimed in claim 6, which is characterized in that the parameter configuration module, including:
Server info acquiring unit obtains server at least two optional environment to be connected to same server in advance
Information;
Parameter acquiring unit is configured, the configuration parameter for obtaining the optional environment, the configuration parameter includes IP and port
Number;
Switch acquiring unit, the identifier for determining macrodefinition based on the server info, and by the IP and port numbers
As the character string of macrodefinition, to obtain macrodefinition switch corresponding with the optional environment.
8. environment dynamic switching device as claimed in claim 6, which is characterized in that the environment dynamic switching device also wraps
It includes:
On off state setting unit, the on off state for macrodefinition switch described in default setting are idle state;
The environment dynamic switching device further includes:
On off state switch unit, the on off state for switching the target macrodefinition are switched to state of activation.
9. a kind of computer equipment, including memory, processor and it is stored in the memory and can be in the processor
The computer program of upper operation, which is characterized in that the processor realized when executing the computer program as claim 1 to
The step of any one of 5 environment dynamic switching method.
10. a kind of computer readable storage medium, the computer-readable recording medium storage has computer program, feature to exist
In realizing the environment dynamic switching method as described in any one of claim 1 to 5 when the computer program is executed by processor
Step.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810435800.4A CN108664270A (en) | 2018-05-09 | 2018-05-09 | Environment dynamic switching method, device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810435800.4A CN108664270A (en) | 2018-05-09 | 2018-05-09 | Environment dynamic switching method, device, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108664270A true CN108664270A (en) | 2018-10-16 |
Family
ID=63778761
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810435800.4A Pending CN108664270A (en) | 2018-05-09 | 2018-05-09 | Environment dynamic switching method, device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108664270A (en) |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109728951A (en) * | 2018-12-28 | 2019-05-07 | 北京小米移动软件有限公司 | Server environment switching method and device |
CN109976619A (en) * | 2019-03-27 | 2019-07-05 | 携程计算机技术(上海)有限公司 | The switching system and method for wechat small routine running environment |
CN110046094A (en) * | 2019-03-15 | 2019-07-23 | 北京创鑫旅程网络技术有限公司 | The switching method of running environment and the switching device of running environment |
CN110351134A (en) * | 2019-06-28 | 2019-10-18 | 北京你财富计算机科技有限公司 | A kind of server environment switching method, device and electronic equipment |
CN110442397A (en) * | 2019-08-05 | 2019-11-12 | 西安瑜乐文化科技股份有限公司 | A kind of configuration surroundings switching method and device |
CN111381836A (en) * | 2018-12-29 | 2020-07-07 | 北京奇虎科技有限公司 | Switching method and device of application program deployment environment |
CN112131126A (en) * | 2020-09-28 | 2020-12-25 | 中国银行股份有限公司 | Test environment switching method and device |
CN113127053A (en) * | 2021-04-29 | 2021-07-16 | 平安国际智慧城市科技股份有限公司 | Application environment parameter configuration method and device, computer equipment and storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101408762A (en) * | 2007-09-28 | 2009-04-15 | 洛克威尔自动控制技术股份有限公司 | Programmable controller programming with embedded macro capability |
CN103577907A (en) * | 2012-07-24 | 2014-02-12 | 阿里巴巴集团控股有限公司 | Continuous integration testing method and system |
CN104572206A (en) * | 2015-01-14 | 2015-04-29 | 厦门为那通信科技有限公司 | Application program self updating and backup recovery method |
CN106020877A (en) * | 2016-05-16 | 2016-10-12 | 乐视控股(北京)有限公司 | Automatic update method and apparatus for system environment configuration |
CN107168726A (en) * | 2017-03-30 | 2017-09-15 | 武汉斗鱼网络科技有限公司 | A kind of method and apparatus of dynamic configuration application program |
CN107357558A (en) * | 2016-05-10 | 2017-11-17 | 阿里巴巴集团控股有限公司 | Build the method and device of code |
-
2018
- 2018-05-09 CN CN201810435800.4A patent/CN108664270A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101408762A (en) * | 2007-09-28 | 2009-04-15 | 洛克威尔自动控制技术股份有限公司 | Programmable controller programming with embedded macro capability |
CN103577907A (en) * | 2012-07-24 | 2014-02-12 | 阿里巴巴集团控股有限公司 | Continuous integration testing method and system |
CN104572206A (en) * | 2015-01-14 | 2015-04-29 | 厦门为那通信科技有限公司 | Application program self updating and backup recovery method |
CN107357558A (en) * | 2016-05-10 | 2017-11-17 | 阿里巴巴集团控股有限公司 | Build the method and device of code |
CN106020877A (en) * | 2016-05-16 | 2016-10-12 | 乐视控股(北京)有限公司 | Automatic update method and apparatus for system environment configuration |
CN107168726A (en) * | 2017-03-30 | 2017-09-15 | 武汉斗鱼网络科技有限公司 | A kind of method and apparatus of dynamic configuration application program |
Cited By (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109728951A (en) * | 2018-12-28 | 2019-05-07 | 北京小米移动软件有限公司 | Server environment switching method and device |
CN111381836A (en) * | 2018-12-29 | 2020-07-07 | 北京奇虎科技有限公司 | Switching method and device of application program deployment environment |
CN111381836B (en) * | 2018-12-29 | 2024-02-06 | 三六零科技集团有限公司 | Application deployment environment switching method and device |
CN110046094A (en) * | 2019-03-15 | 2019-07-23 | 北京创鑫旅程网络技术有限公司 | The switching method of running environment and the switching device of running environment |
CN109976619A (en) * | 2019-03-27 | 2019-07-05 | 携程计算机技术(上海)有限公司 | The switching system and method for wechat small routine running environment |
CN110351134A (en) * | 2019-06-28 | 2019-10-18 | 北京你财富计算机科技有限公司 | A kind of server environment switching method, device and electronic equipment |
CN110442397A (en) * | 2019-08-05 | 2019-11-12 | 西安瑜乐文化科技股份有限公司 | A kind of configuration surroundings switching method and device |
CN112131126A (en) * | 2020-09-28 | 2020-12-25 | 中国银行股份有限公司 | Test environment switching method and device |
CN112131126B (en) * | 2020-09-28 | 2023-10-27 | 中国银行股份有限公司 | Switching method and device of test environment |
CN113127053A (en) * | 2021-04-29 | 2021-07-16 | 平安国际智慧城市科技股份有限公司 | Application environment parameter configuration method and device, computer equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108664270A (en) | Environment dynamic switching method, device, computer equipment and storage medium | |
CN110727697B (en) | Data processing method and device, storage medium and electronic device | |
WO2018210096A1 (en) | Rule engine-based rule configuration method, terminal and device, and storage medium | |
CN112565443A (en) | Internet of things data analysis method, device, equipment and storage medium | |
CN110096380B (en) | Android internal communication method, system, device and storage medium | |
WO2019075845A1 (en) | Construction method and device for link call relationship, computer device and storage medium | |
CN112073923A (en) | Communication method, device, gateway and readable storage medium compatible with multiple operators | |
CN110187986B (en) | Command management method, system, device and computer readable storage medium | |
CN113407469B (en) | Parameter configuration method and device, storage medium and electronic device | |
CN113900939A (en) | Test environment access method and device, readable storage medium and computer equipment | |
CN108604996A (en) | A kind of strategy transmission method and apparatus in NFV systems | |
Ratan | Practical Network Automation: Leverage the power of Python and Ansible to optimize your network | |
CN109933411B (en) | System and method for modifying internal configuration of virtual machine on line | |
CN112073488A (en) | Method and device for processing request | |
CN114745280B (en) | Asset information management method, device, equipment and readable storage medium | |
CN115904388A (en) | Application program protocol analysis method, device, equipment and storage medium | |
CN115146309A (en) | Privacy compliance detection method, device, server, terminal and storage medium | |
CN104967696A (en) | Log sending method and device | |
CN109728951A (en) | Server environment switching method and device | |
CN110324345B (en) | Server login method and device, storage medium and terminal | |
CN113326186A (en) | Software testing method and device, electronic equipment and storage medium | |
CN112181802A (en) | Test method and device | |
CN113626295A (en) | Pressure measurement data processing method and system and computer readable storage medium | |
CN111026317A (en) | Method, device and storage medium for determining user operation | |
CN110609781A (en) | Interface test method, device and storage medium |
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 | ||
AD01 | Patent right deemed abandoned |
Effective date of abandoning: 20240220 |
|
AD01 | Patent right deemed abandoned |