CN110046094B - Operating environment switching method and operating environment switching device - Google Patents

Operating environment switching method and operating environment switching device Download PDF

Info

Publication number
CN110046094B
CN110046094B CN201910199229.5A CN201910199229A CN110046094B CN 110046094 B CN110046094 B CN 110046094B CN 201910199229 A CN201910199229 A CN 201910199229A CN 110046094 B CN110046094 B CN 110046094B
Authority
CN
China
Prior art keywords
production environment
environment
production
configuration file
identifier
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910199229.5A
Other languages
Chinese (zh)
Other versions
CN110046094A (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 Chuangxin Journey Network Technology Co ltd
Original Assignee
Beijing Chuangxin Journey Network 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 Chuangxin Journey Network Technology Co ltd filed Critical Beijing Chuangxin Journey Network Technology Co ltd
Priority to CN201910199229.5A priority Critical patent/CN110046094B/en
Publication of CN110046094A publication Critical patent/CN110046094A/en
Application granted granted Critical
Publication of CN110046094B publication Critical patent/CN110046094B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3696Methods or tools to render software testable
    • 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
    • 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/44536Selecting among different versions

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Stored Programmes (AREA)

Abstract

The present disclosure relates to a method and a device for switching operating environments, in the method for switching operating environments, the operating environments include a non-production environment, and the method for switching operating environments includes: receiving a selection command containing a valid environment identifier in environment identifiers in the constructed project; judging whether sub non-production environment identifications included in a plurality of sub non-production environments in the non-production environment are matched with the effective environment identifications; loading a sub non-production environment configuration file corresponding to the sub non-production environment identifier matched with the effective environment identifier; and executing the build compiling command according to the sub non-production environment configuration file so as to automatically switch to the sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier. The switching method of the operating environment can realize automatic switching among the operating environment codes, has simple and convenient flow, reduces the error probability and improves the efficiency of development and test.

Description

Operating environment switching method and operating environment switching device
Technical Field
The present disclosure relates to the field of communications technologies, and in particular, to a method and an apparatus for switching an operating environment.
Background
Before the application software of the mobile terminal or the PC terminal based on the web front end is online, various tests are performed, and during the test, the operating environment of the mobile terminal or the PC terminal needs to be frequently switched. At present, developers usually modify corresponding domain names manually in a test-up stage, a pre-release deployment stage and an online deployment stage to realize switching among various operating environments. The purely manual modification mode easily causes domain name errors, is not convenient enough, and brings troubles to developers.
Disclosure of Invention
The domain name modification by a purely manual method cannot realize automatic switching among various operating environments. In order to solve the above problems, the present disclosure provides a switching method and a switching device for an operating environment, which can automatically switch an operating environment, so as to solve the technical problem that automatic switching cannot be performed between the operating environments.
According to one aspect of the present disclosure, there is provided a method for switching an operating environment, the operating environment including a non-production environment, the method for switching an operating environment including: receiving a selection command containing a valid environment identifier in environment identifiers in the constructed project; judging whether sub non-production environment identifications included in a plurality of sub non-production environments in the non-production environment are matched with the effective environment identifications; loading a sub non-production environment configuration file corresponding to the sub non-production environment identifier matched with the effective environment identifier; and executing the build compiling command according to the sub non-production environment configuration file so as to automatically switch to the sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier.
In some embodiments, the method for switching the operating environment further includes: a run environment switch option is provided in response to the start operation command prior to receiving the selection command containing the valid environment identification.
In some embodiments, the runtime environment switch option includes a runtime environment switch interface that includes selection buttons for an online environment, a development environment, a test environment, and a pre-release environment.
In some embodiments, the runtime environment further comprises a production environment, the sub non-production environment configuration file comprises a sub non-production environment configuration object, the sub non-production environment configuration object comprises a sub non-production environment domain name, and the sub non-production environment configuration file is formed by: creating a production environment configuration file of a production environment and a non-production environment configuration file of a non-production environment, wherein the production environment configuration file comprises a production environment identifier and a production environment configuration object, the non-production environment configuration file comprises a non-production environment identifier and a non-production environment configuration object, and the non-production environment configuration object comprises a non-production environment domain name; importing the exported production environment configuration object into a non-production environment configuration object; setting a non-production environment identifier according to an environment identifier in the constructed project; rewriting the non-production environment domain name of the imported non-production environment configuration object into a sub non-production environment domain name to form the non-production environment configuration file into a sub non-production environment configuration file.
In some embodiments, executing the build compilation command to automatically switch to the child non-production environment corresponding to the child non-production environment identification that matches the valid environment identification according to the child non-production environment configuration file comprises: reading a sub non-production environment configuration file, wherein the sub non-production environment configuration file comprises a sub non-production environment configuration object, and the sub non-production environment configuration object comprises a sub non-production environment domain name; assigning a domain name variable of the constructed project as a sub non-production environment domain name; and executing a build compiling command according to the code corresponding to the domain name variable assigned as the domain name of the sub non-production environment and the operation environment switching option so as to switch to the sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier.
In some embodiments, the operation environment further includes a production environment, and the switching method of the operation environment further includes: receiving a selection command of a production environment containing a production environment identifier from a client; reading a production environment configuration file based on the production environment identifier; loading a production environment configuration file; and executing the build compiling command according to the production environment configuration file to switch to the production environment.
According to another aspect of the present disclosure, there is provided a switching apparatus of an execution environment, the execution environment including a non-production environment, the switching apparatus of the execution environment including: a selection command receiving module configured to receive a selection command containing a valid environment identifier among environment identifiers in the constructed project; the environment identifier matching module is configured for judging whether the sub non-production environment identifiers included in a plurality of sub non-production environments in the non-production environment are matched with the effective environment identifiers or not; the configuration file loading module is used for loading a sub non-production environment configuration file corresponding to the sub non-production environment identifier matched with the effective environment identifier; and the environment switching module is configured for executing the compiling command according to the sub non-production environment configuration file so as to automatically switch to the sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier.
In some embodiments, the switching device of the operation environment further includes: and a switching option providing module configured to provide a running environment switching option in response to the start operation command before receiving the selection command containing the valid environment identification.
In some embodiments, in the switching device of the execution environment, the execution environment switching option includes an execution environment switching interface including selection buttons of an online environment, a development environment, a test environment, and a pre-release environment.
In some embodiments, the runtime environment further comprises a production environment, the sub non-production environment configuration file comprises a sub non-production environment configuration object, the sub non-production environment configuration object comprises a sub non-production environment domain name, and the sub non-production environment configuration file is formed by: creating a production environment configuration file of a production environment and a non-production environment configuration file of a non-production environment, wherein the production environment configuration file comprises a production environment identifier and a production environment configuration object, the non-production environment configuration file comprises a non-production environment identifier and a non-production environment configuration object, and the non-production environment configuration object comprises a non-production environment domain name; importing the exported production environment configuration object into a non-production environment configuration object; setting a non-production environment identifier according to an environment identifier in the constructed project; rewriting the non-production environment domain name of the imported non-production environment configuration object into a sub non-production environment domain name to form the non-production environment configuration file into a sub non-production environment configuration file.
In some embodiments, the context switch module comprises: reading a sub non-production environment configuration file, wherein the sub non-production environment configuration file comprises a sub non-production environment configuration object, and the sub non-production environment configuration object comprises a sub non-production environment domain name; assigning a domain name variable of the constructed project as a sub non-production environment domain name; and executing a build compiling command according to the code corresponding to the domain name variable assigned as the domain name of the sub non-production environment and the operation environment switching option so as to switch to the sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier.
In some embodiments, in the switching device of the execution environment, the execution environment further includes a production environment, and the switching device of the execution environment further includes: the production environment selection command receiving module is configured for receiving a selection command of a production environment containing a production environment identifier from the client; a production environment configuration file reading module configured to read a production environment configuration file based on the production environment identifier; the production environment configuration file loading module is configured for loading a production environment configuration file; and the production environment switching module is configured for executing the build compiling command according to the production environment configuration file so as to switch to the production environment.
According to yet another aspect of the disclosure, a computer-readable storage medium is provided, having stored thereon computer-executable instructions that, when executed by a processor, perform any of the foregoing methods.
According to still another aspect of the present disclosure, there is provided an electronic apparatus including: a memory configured to store instructions; and a processor configured to invoke the instructions to perform any of the foregoing methods.
The switching method of the operating environment can realize automatic switching among the operating environment codes, has simple and convenient flow, reduces the error probability and improves the efficiency of development and test.
Drawings
The above and other objects, features and advantages of embodiments of the present invention will become readily apparent from the following detailed description read in conjunction with the accompanying drawings. Several embodiments of the invention are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which:
fig. 1 is a flowchart of a switching method of an execution environment according to a first exemplary embodiment of the present disclosure;
FIG. 2 is a view of an exemplary Start operation interface for a method of switching operating environments according to the present disclosure;
FIG. 3 is a view of an exemplary runtime environment switching interface for a method of switching runtime environments according to the present disclosure;
fig. 4 is a block diagram of a switching device of an execution environment according to a second exemplary embodiment of the present disclosure.
Detailed Description
The present inventive concept will be described more fully hereinafter with reference to the accompanying drawings, in which exemplary embodiments of the inventive concept are shown. As those skilled in the art will recognize, the described embodiments may be modified in various different ways, all without departing from the spirit or scope of the inventive concept.
The solution provided by the present disclosure will be described in detail below.
Fig. 1 is a flowchart of a switching method of an execution environment according to a first exemplary embodiment of the present disclosure.
In the first exemplary embodiment, referring to fig. 1, in step S110, a selection command containing a valid one of environment identifications among built items is received.
In some embodiments, when a test project is developed on a PC side or a mobile side, a web front-end developer needs to frequently switch among various operating environments to modify debugging codes and detect bugs, where the operating environments may include a non-production environment, the non-production environment may include a plurality of sub-non-production environments, and the plurality of sub-non-production environments may include an online environment, a development environment, a test environment, a pre-release environment, and the like. However, the above are merely examples, and the present disclosure is not limited thereto.
In some embodiments, a selection command may be issued by the developer, the selection command including a valid environment identifier of environment identifiers in the constructed project, and the selection command including the valid environment identifier may be received by the construction apparatus. The environment identifier in the constructed project may include an environment identifier corresponding to the online environment option, an environment identifier corresponding to the development environment option, an environment identifier corresponding to the test environment option, an environment identifier corresponding to the pre-release environment option, and the like. However, the above are merely examples, and the present disclosure is not limited thereto.
In step S120, it is determined whether a child non-production environment identification included in a plurality of child non-production environments in the non-production environment matches the valid environment identification.
In some embodiments, the build device may include a non-production environment profile, which may include a plurality of sub-non-production environment profiles including sub-non-production environment identifications, such as a sub-non-production environment identification "prod" corresponding to the online environment, a sub-non-production environment identification "dev" corresponding to the development environment, a sub-non-production environment identification "qa" corresponding to the test environment, and a sub-non-production environment identification "sim" corresponding to the pre-release environment, among others. However, the above are merely examples, and the present disclosure is not limited thereto.
In some embodiments, the construction apparatus determines whether a sub non-production environment identifier in the plurality of sub non-production environment profiles matches the valid environment identifier after receiving the selection command containing the valid environment identifier.
In step S130, the sub non-production environment configuration file corresponding to the sub non-production environment identifier matching the valid environment identifier is loaded.
In some embodiments, the sub non-production environment configuration file may include a sub non-production environment identification and a sub non-production environment configuration object, which may include a sub non-production environment domain name. Further, the child non-production environment configuration objects may also include other configuration objects, although the disclosure is not so limited.
In some embodiments, the construction apparatus may load the sub non-production environment configuration file corresponding to the sub non-production environment identifier matching the valid environment identifier after determining that the sub non-production environment identifier in a certain sub non-production environment configuration file matches the valid environment identifier.
In step S140, a build compilation command is executed according to the sub non-production environment configuration file to automatically switch to the sub non-production environment corresponding to the sub non-production environment identifier matching the valid environment identifier.
In some embodiments, the build mechanism may execute the build compilation command according to the sub-non-production environment configuration file to automatically switch to the sub-non-production environment corresponding to the sub-non-production environment identifier matching the valid environment identifier.
According to the switching method of the operating environment of the first exemplary embodiment of the disclosure, automatic switching among the operating environment codes can be realized, the process is simple and convenient, the error probability is reduced, and the efficiency of development and testing is improved.
Further, in some embodiments of the present disclosure, a run environment switch option is provided in response to the start operation command prior to receiving the selection command containing the valid environment identification.
Fig. 2 is a view of an exemplary start operation interface of the switching method of the execution environment according to the present disclosure. As shown in FIG. 2, an exemplary start operation interface may include a "start" button located at the lower right corner of the front of the web. In an example, a developer may click a "start" button to issue a start operation command, in response to which the build device provides the developer with a runtime environment switching interface.
However, the above are merely examples, and the present disclosure is not limited thereto. The "start" button described above may be located at any suitable location on the front end of the web and may also be shown in any suitable manner, such as by way of an icon. Further, the "start" button may be a button that switches between "on"/"off".
Further, in an example, the "start" button may be suspended in a semi-transparent manner on the web front end so as not to affect any other content displayed by the web front end; alternatively, the "start" button may be hidden or semi-hidden at the border in the lower right corner of the front of the web. However, the above are merely examples, and the present disclosure is not limited thereto.
Further, in some embodiments of the present disclosure, the runtime environment switching option may include a runtime environment switching interface, which may include selection buttons for an online environment, a development environment, a test environment, and a pre-release environment.
Fig. 3 is a view of an exemplary execution environment switching interface of the switching method of the execution environment according to the present disclosure. As shown in fig. 3, an exemplary runtime environment switching interface may include an "online environment" option button, a "development environment" option button, a "test environment" option button, and a "pre-release environment" option button located at the lower right corner of the front end of the web, and an "ok" button located below and to the right of the above-described option buttons, but the disclosure is not limited thereto. The combination of the above-mentioned buttons for options may be located at any suitable position on the front end of the web, and the individual option buttons in the above-mentioned combination of buttons for options may also be arranged in any suitable order and manner, and the size of the above-mentioned option buttons may also be adjusted as needed. In an example, the "ok" button may not be included, but the selection command may be directly issued by clicking the above-described option button.
In an example, the developer may click on any one of an "online environment" option button, a "development environment" option button, a "test environment" option button, and a "pre-release environment" option button, and then click on a "ok" button, thereby issuing a selection command containing a valid one of the environment identifiers in the constructed project, which is received by the construction apparatus. However, the above are merely examples, and the present disclosure is not limited thereto. In other examples, the runtime environment switch interface may also include option buttons for other non-production environments suitable for developer development, testing, and detection.
Further, in an example, the combination of buttons of the above options may be suspended in a semi-transparent manner on the web front end so as not to affect any other content displayed by the web front end; alternatively, a combination of the above options may be hidden or semi-hidden at the border of the lower right corner of the front of the web. However, the above are merely examples, and the present disclosure is not limited thereto. Combinations of the above options' buttons may also be shown in the web front end in any suitable manner.
The switching method of the operating environment can provide a proper operating environment switching interface under the condition of not influencing the display content of the web front end, achieves interference-free operation, and is attractive and friendly in interface and convenient and rapid to operate.
Furthermore, in some embodiments of the present disclosure, the runtime environment may further include a production environment, the sub non-production environment configuration file may include a sub non-production environment configuration object, the sub non-production environment configuration object may include a sub non-production environment domain name, and the sub non-production environment configuration file may be formed by: creating a production environment configuration file of a production environment and a non-production environment configuration file of a non-production environment, wherein the production environment configuration file comprises a production environment identifier and a production environment configuration object, the non-production environment configuration file comprises a non-production environment identifier and a non-production environment configuration object, and the non-production environment configuration object comprises a non-production environment domain name; importing the exported production environment configuration object into a non-production environment configuration object; setting a non-production environment identifier according to an environment identifier in the constructed project; rewriting the non-production environment domain name of the imported non-production environment configuration object into a sub non-production environment domain name to form the non-production environment configuration file into a sub non-production environment configuration file.
In some embodiments, since code in the production environment cannot be contaminated, to achieve complete isolation of the production environment from the non-production environment, a developer may create two files, a production environment profile for the production environment and a non-production environment profile for the non-production environment in the built project. The configuration object of the required domain name in the production environment can be configured in the production environment configuration file and can be exported. In a normal case, the domain name of the pre-release environment in the non-production environment is the same as the domain name of the production environment in the production environment, and the exported production environment configuration object is imported into the non-production environment configuration object in order to reduce code duplication and errors. Then, a non-production environment identifier is set according to the environment identifier in the constructed project. And finally, rewriting the imported non-production environment domain name of the non-production environment configuration object into a sub-non-production environment domain name, so that the non-production environment configuration file is formed into a sub-non-production environment configuration file.
The switching method of the operating environment provided by the disclosure can avoid the risk of manually changing codes by increasing the configuration files, and reduce the error probability; the complete isolation of the production environment and the non-production environment is realized, and the effect of no code pollution is achieved.
Further, in some embodiments of the present disclosure, executing the build compilation command according to the sub non-production environment configuration file in the switching method of the execution environment to automatically switch to the sub non-production environment corresponding to the sub non-production environment identifier matching the valid environment identifier includes: reading a sub non-production environment configuration file, wherein the sub non-production environment configuration file comprises a sub non-production environment configuration object, and the sub non-production environment configuration object comprises a sub non-production environment domain name; assigning a domain name variable of the constructed project as a sub non-production environment domain name; and executing a build compiling command according to the code corresponding to the domain name variable assigned as the domain name of the sub non-production environment and the operation environment switching option so as to switch to the sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier.
In some embodiments, the build device may read the sub non-production environment configuration file and assign the domain name variable of the built project to the sub non-production environment domain name. Then, the construction device can execute the construction compiling command according to the code corresponding to the domain name variable assigned as the domain name of the sub non-production environment and the operation environment switching option, and render the code, so that the web front-end display content is switched to the sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier. At this point, the runtime environment switch option may still optionally be shown on the web front end.
The switching method of the operating environment can switch the options through the visual operating environment, the interactivity is better, the interface is clear, and the environment switching is more convenient.
Furthermore, in some embodiments of the present disclosure, the operation environment further includes a production environment, and the switching method of the operation environment may further include: receiving a selection command of a production environment containing a production environment identifier from a client; reading a production environment configuration file based on the production environment identifier; loading a production environment configuration file; and executing the build compiling command according to the production environment configuration file to switch to the production environment.
In some embodiments, the build device may receive a selection command from the client for a production environment including a production environment identification, and read a production environment configuration file based on the production environment identification. Then, the build device may load the production environment configuration file and execute the build compilation command to switch to the production environment according to the production environment configuration file.
The switching method of the operating environment provided by the disclosure can realize the complete isolation of the production environment and the non-production environment under the condition of no code pollution; the performance is stable, and the system maintainability is better.
The method for switching the operating environments in the above exemplary embodiment may be applied to a mobile terminal and a PC terminal, where the mobile terminal includes a smart phone, a tablet computer, a notebook computer, and the like, and the PC terminal includes a personal desktop computer, a server, and the like.
Fig. 4 is a block diagram of a switching device of an execution environment according to a second exemplary embodiment of the present disclosure. In fig. 4, the switching device 2000 of the operation environment may include: a selection command receiving module 210, an environment identification matching module 220, a configuration file loading module 230, and an environment switching module 240.
Specifically, in the switching device 2000 of the operation environment, the operation environment may include a non-production environment, and the switching device 2000 of the operation environment may include: a selection command receiving module 210 configured to receive a selection command containing a valid environment identifier of environment identifiers in the constructed item; an environment identifier matching module 220 configured to determine whether a sub non-production environment identifier included in a plurality of sub non-production environments in the non-production environment matches with the valid environment identifier; a configuration file loading module 230 configured to load a sub non-production environment configuration file corresponding to the sub non-production environment identifier matched with the valid environment identifier; and the environment switching module 240 is configured to execute the build compiling command according to the sub non-production environment configuration file to automatically switch to the sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier.
In some embodiments, the switching device of the operation environment may further include: and a switching option providing module configured to provide a running environment switching option in response to the start operation command before receiving the selection command containing the valid environment identification.
In some embodiments, in the switching device of the execution environment, the execution environment switching option may include an execution environment switching interface, and the execution environment switching interface may include selection buttons of an online environment, a development environment, a test environment, and a pre-release environment.
In some embodiments, the runtime environment may further include a production environment, the sub non-production environment configuration file may include a sub non-production environment configuration object, the sub non-production environment configuration object may include a sub non-production environment domain name, and the sub non-production environment configuration file may be formed by: creating a production environment configuration file of a production environment and a non-production environment configuration file of a non-production environment, wherein the production environment configuration file comprises a production environment identifier and a production environment configuration object, the non-production environment configuration file comprises a non-production environment identifier and a non-production environment configuration object, and the non-production environment configuration object comprises a non-production environment domain name; importing the exported production environment configuration object into a non-production environment configuration object; setting a non-production environment identifier according to an environment identifier in the constructed project; rewriting the non-production environment domain name of the imported non-production environment configuration object into a sub non-production environment domain name to form the non-production environment configuration file into a sub non-production environment configuration file.
In some embodiments, the context switching module 240 may include: reading a sub non-production environment configuration file, wherein the sub non-production environment configuration file comprises a sub non-production environment configuration object, and the sub non-production environment configuration object comprises a sub non-production environment domain name; assigning a domain name variable of the constructed project as a sub non-production environment domain name; and executing a build compiling command according to the code corresponding to the domain name variable assigned as the domain name of the sub non-production environment and the operation environment switching option so as to switch to the sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier.
In some embodiments, in the switching device of the execution environment, the execution environment further includes a production environment, and the switching device of the execution environment may further include: the production environment selection command receiving module is configured for receiving a selection command of a production environment containing a production environment identifier from the client; a production environment configuration file reading module configured to read a production environment configuration file based on the production environment identifier; the production environment configuration file loading module is configured for loading a production environment configuration file; and the production environment switching module is configured for executing the build compiling command according to the production environment configuration file so as to switch to the production environment.
Furthermore, the present disclosure also provides a computer-readable storage medium, which may store computer-executable instructions that, when executed by a processor, may perform any one of the methods described in the foregoing first exemplary embodiment.
In addition, the present disclosure also provides an electronic device, which may include: a memory configured to store instructions; and a processor configured to invoke the instructions to perform any of the methods described in the foregoing first exemplary embodiment.
In some embodiments, the present invention further provides the following technical solutions:
scheme 1. a method for switching operating environments, wherein the operating environments include a non-production environment, the method comprising:
receiving a selection command containing a valid environment identifier in environment identifiers in the constructed project;
judging whether sub non-production environment identifiers included in a plurality of sub non-production environments in the non-production environment are matched with the effective environment identifiers;
loading a sub non-production environment configuration file corresponding to the sub non-production environment identifier matched with the effective environment identifier;
and executing a compiling command according to the sub non-production environment configuration file so as to automatically switch to the sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier.
Scheme 2. the method of scheme 1, wherein the method further comprises:
a run environment switch option is provided in response to the start operation command prior to receiving the selection command containing the valid environment identification.
Scheme 3. the process according to scheme 2, wherein,
the operation environment switching options comprise operation environment switching interfaces, and the operation environment switching interfaces comprise selection buttons of an online environment, a development environment, a test environment and a pre-release environment.
Scheme 4. the method of scheme 1, wherein the runtime environment further comprises a production environment, the child non-production environment configuration file comprises a child non-production environment configuration object, the child non-production environment configuration object comprises a child non-production environment domain name,
and wherein the child non-production environment profile is formed by:
creating a production environment configuration file of the production environment and a non-production environment configuration file of the non-production environment, wherein the production environment configuration file comprises a production environment identifier and a production environment configuration object, the non-production environment configuration file comprises a non-production environment identifier and a non-production environment configuration object, and the non-production environment configuration object comprises a non-production environment domain name;
importing the exported production environment configuration object into the non-production environment configuration object;
setting the non-production environment identifier according to the environment identifier in the constructed project;
rewriting the imported non-production environment domain name of the non-production environment configuration object into the sub non-production environment domain name to form the non-production environment configuration file into the sub non-production environment configuration file.
Scheme 5. the process according to scheme 1, wherein,
executing a build compilation command according to the sub non-production environment configuration file to automatically switch to a sub non-production environment corresponding to the sub non-production environment identifier that matches the active environment identifier comprises:
reading the sub non-production environment configuration file, wherein the sub non-production environment configuration file comprises a sub non-production environment configuration object which comprises a sub non-production environment domain name;
assigning the domain name variable of the constructed project to the sub non-production environment domain name;
and executing a compiling command according to the code corresponding to the domain name variable assigned as the domain name of the sub non-production environment and the operation environment switching option, so as to switch to the sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier.
Scheme 6. the method of scheme 1, wherein the operating environment further comprises a production environment,
and wherein the method further comprises:
receiving a selection command of a production environment containing a production environment identifier from a client;
reading a production environment configuration file based on the production environment identifier;
loading the production environment configuration file;
and executing a build compiling command according to the production environment configuration file so as to switch to the production environment.
Scheme 7. a switching arrangement of operating environments, wherein the operating environments include non-production environments, the arrangement comprising:
a selection command receiving module configured to receive a selection command containing a valid environment identifier among environment identifiers in the constructed project;
an environment identifier matching module configured to determine whether a sub non-production environment identifier included in a plurality of sub non-production environments in the non-production environment matches the valid environment identifier;
the configuration file loading module is used for loading a sub non-production environment configuration file corresponding to the sub non-production environment identifier matched with the effective environment identifier;
and the environment switching module is configured to execute a build compiling command according to the sub non-production environment configuration file so as to automatically switch to the sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier.
The apparatus of aspect 7, wherein the apparatus further comprises:
and a switching option providing module configured to provide a running environment switching option in response to the start operation command before receiving the selection command containing the valid environment identification.
Scheme 9. the apparatus of scheme 8, wherein,
the operation environment switching options comprise operation environment switching interfaces, and the operation environment switching interfaces comprise selection buttons of an online environment, a development environment, a test environment and a pre-release environment.
The apparatus of scheme 10, wherein the runtime environment further comprises a production environment, the child non-production environment configuration file comprises a child non-production environment configuration object, the child non-production environment configuration object comprises a child non-production environment domain name,
and wherein the child non-production environment profile is formed by:
creating a production environment configuration file of the production environment and a non-production environment configuration file of the non-production environment, wherein the production environment configuration file comprises a production environment identifier and a production environment configuration object, the non-production environment configuration file comprises a non-production environment identifier and a non-production environment configuration object, and the non-production environment configuration object comprises a non-production environment domain name;
importing the exported production environment configuration object into the non-production environment configuration object;
setting the non-production environment identifier according to the environment identifier in the constructed project;
rewriting the imported non-production environment domain name of the non-production environment configuration object into the sub non-production environment domain name to form the non-production environment configuration file into the sub non-production environment configuration file.
Scheme 11. the apparatus of scheme 7, wherein,
the context switching module includes:
reading the sub non-production environment configuration file, wherein the sub non-production environment configuration file comprises a sub non-production environment configuration object which comprises a sub non-production environment domain name;
assigning the domain name variable of the constructed project to the sub non-production environment domain name;
and executing a compiling command according to the code corresponding to the domain name variable assigned as the domain name of the sub non-production environment and the operation environment switching option, so as to switch to the sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier.
The apparatus of scheme 12, wherein the operating environment further comprises a production environment,
and wherein the apparatus further comprises:
the production environment selection command receiving module is configured for receiving a selection command of a production environment containing a production environment identifier from the client;
a production environment configuration file reading module configured to read a production environment configuration file based on the production environment identifier;
a production environment configuration file loading module configured to load the production environment configuration file;
and the production environment switching module is configured for executing a build compiling command according to the production environment configuration file so as to switch to the production environment.
Scheme 13. a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions that, when executed by a processor, perform the method of any of schemes 1-6.
Scheme 14. an electronic device, comprising:
a memory configured to store instructions; and
a processor configured to invoke the method of any of the instruction execution scenarios 1-6.
According to the switching method and the switching device for the operating environment, automatic switching among the operating environment codes can be realized, the process is simple and convenient, the error probability is reduced, and the efficiency of development and testing is improved.
In the switching method and the switching device of the operating environment, complete isolation between the production environment and the non-production environment can be realized, so that codes in the production environment are not polluted.
In the switching method and the switching device of the operating environment, the system maintenance performance can be better by increasing the configuration files; the switching device of visual operational environment of accessible, the interactivity is better for the switching of operational environment is more convenient.
Although operations are depicted in the drawings in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in serial order, or that all illustrated operations be performed, to achieve desirable results. In certain environments, multitasking and parallel processing may be advantageous.
The methods and apparatus of the present invention can be accomplished with standard programming techniques with rule based logic or other logic to accomplish the various method steps. It should also be noted that the words "means" and "module," as used herein and in the claims, is intended to encompass implementations using one or more lines of software code, and/or hardware implementations, and/or equipment for receiving inputs.
Any of the steps, operations, or procedures described herein may be performed or implemented using one or more hardware or software modules, alone or in combination with other devices. In one embodiment, the software modules are implemented using a computer program product comprising a computer readable medium containing computer program code, which is executable by a computer processor for performing any or all of the described steps, operations, or procedures.
The foregoing description of the implementation of the invention has been presented for purposes of illustration and description. It is not intended to be exhaustive or to limit the invention to the precise form disclosed, and modifications and variations are possible in light of the above teachings or may be acquired from practice of the invention. The embodiments were chosen and described in order to explain the principles of the invention and its practical application to enable one skilled in the art to utilize the invention in various embodiments and with various modifications as are suited to the particular use contemplated.

Claims (12)

1. A method for switching an execution environment, wherein the method is applied to a construction device, the construction device comprises a non-production environment configuration file, the execution environment comprises a non-production environment and a production environment, and the method comprises the following steps:
receiving a selection command, wherein the selection command comprises a selection command of an effective environment identifier in environment identifiers in a constructed project or a selection command of a production environment identifier of a production environment;
if receiving a selection command containing an effective environment identifier in the environment identifiers in the constructed project;
judging whether sub non-production environment identifiers included in a plurality of sub non-production environments in the non-production environment are matched with the effective environment identifiers;
loading a sub non-production environment configuration file corresponding to a sub non-production environment identifier matched with the effective environment identifier in the non-production environment configuration file;
assigning a domain name variable of the constructed project to be a domain name of a sub non-production environment according to the configuration file of the sub non-production environment, executing a construction compiling command, and automatically switching the web front-end display content to the sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier;
wherein the sub non-production environment configuration file comprises a sub non-production environment configuration object comprising a sub non-production environment domain name,
and wherein the child non-production environment profile is formed by:
creating a production environment configuration file of the production environment and a non-production environment configuration file of the non-production environment, wherein the production environment configuration file comprises a production environment identifier and a production environment configuration object, the non-production environment configuration file comprises a non-production environment identifier and a non-production environment configuration object, and the non-production environment configuration object comprises a non-production environment domain name;
importing the exported production environment configuration object into the non-production environment configuration object;
setting the non-production environment identifier according to the environment identifier in the constructed project;
rewriting the imported non-production environment domain name of the non-production environment configuration object into the sub non-production environment domain name to form the non-production environment configuration file into the sub non-production environment configuration file.
2. The method of claim 1, wherein the method further comprises:
a run environment switch option is provided in response to the start operation command prior to receiving the selection command containing the valid environment identification.
3. The method of claim 2, wherein,
the operation environment switching options comprise operation environment switching interfaces, and the operation environment switching interfaces comprise selection buttons of an online environment, a development environment, a test environment and a pre-release environment.
4. The method of claim 1, wherein,
assigning a domain name variable of the constructed project to the domain name of the sub non-production environment according to the configuration file of the sub non-production environment, executing a construction compiling command, and automatically switching the web front-end display content to the sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier comprises the following steps:
reading the sub non-production environment configuration file, wherein the sub non-production environment configuration file comprises a sub non-production environment configuration object which comprises a sub non-production environment domain name;
assigning the domain name variable of the constructed project to the sub non-production environment domain name;
and executing and constructing a compiling command according to the codes corresponding to the domain name variables assigned as the domain names of the sub non-production environments and the operation environment switching options, and switching the web front-end display content to the sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier.
5. The method of claim 1, wherein the operating environment further comprises a production environment,
and wherein the method further comprises:
receiving a selection command of a production environment containing a production environment identifier from a client;
reading a production environment configuration file based on the production environment identifier;
loading the production environment configuration file;
and executing a build compiling command according to the production environment configuration file so as to switch to the production environment.
6. A switching apparatus of an execution environment, applied to a construction apparatus including a non-production environment configuration file, the execution environment including a non-production environment and a production environment, the switching apparatus of the execution environment comprising:
a selection command receiving module configured to receive a selection command, where the selection command includes a selection command of an effective environment identifier in environment identifiers in a constructed project or a selection command of a production environment identifier of a production environment;
if receiving a selection command containing an effective environment identifier in the environment identifiers in the constructed project;
an environment identifier matching module configured to determine whether a sub non-production environment identifier included in a plurality of sub non-production environments in the non-production environment matches the valid environment identifier;
a configuration file loading module configured to load a sub non-production environment configuration file corresponding to the sub non-production environment identifier matched with the effective environment identifier in the non-production environment configuration file;
the environment switching module is configured to assign a domain name variable of the constructed project to a sub non-production environment domain name according to the sub non-production environment configuration file, execute a construction compiling command, and automatically switch the web front-end display content to a sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier;
wherein the sub non-production environment configuration file comprises a sub non-production environment configuration object comprising a sub non-production environment domain name,
and wherein the child non-production environment profile is formed by:
creating a production environment configuration file of the production environment and a non-production environment configuration file of the non-production environment, wherein the production environment configuration file comprises a production environment identifier and a production environment configuration object, the non-production environment configuration file comprises a non-production environment identifier and a non-production environment configuration object, and the non-production environment configuration object comprises a non-production environment domain name;
importing the exported production environment configuration object into the non-production environment configuration object;
setting the non-production environment identifier according to the environment identifier in the constructed project;
rewriting the imported non-production environment domain name of the non-production environment configuration object into the sub non-production environment domain name to form the non-production environment configuration file into the sub non-production environment configuration file.
7. The execution environment switching apparatus of claim 6, wherein the execution environment switching apparatus further comprises:
and a switching option providing module configured to provide a running environment switching option in response to the start operation command before receiving the selection command containing the valid environment identification.
8. The switching apparatus of an operating environment according to claim 7,
the operation environment switching options comprise operation environment switching interfaces, and the operation environment switching interfaces comprise selection buttons of an online environment, a development environment, a test environment and a pre-release environment.
9. The switching apparatus of an operating environment according to claim 6,
the context switching module includes:
reading the sub non-production environment configuration file, wherein the sub non-production environment configuration file comprises a sub non-production environment configuration object which comprises a sub non-production environment domain name;
assigning the domain name variable of the constructed project to the sub non-production environment domain name;
and executing a compiling and constructing command according to the codes corresponding to the domain name variables assigned as the domain names of the sub non-production environments and the operation environment switching options to switch the web front-end display content to the sub non-production environment corresponding to the sub non-production environment identifier matched with the effective environment identifier.
10. The switching device of the execution environment of claim 6, wherein the execution environment further comprises a production environment,
and wherein the switching means of the operating environment further comprises:
the production environment selection command receiving module is configured for receiving a selection command of a production environment containing a production environment identifier from the client;
a production environment configuration file reading module configured to read a production environment configuration file based on the production environment identifier;
a production environment configuration file loading module configured to load the production environment configuration file;
and the production environment switching module is configured for executing a build compiling command according to the production environment configuration file so as to switch to the production environment.
11. A computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions that, when executed by a processor, perform the method of any of claims 1-5.
12. An electronic device, comprising:
a memory configured to store instructions; and
a processor configured to invoke the instructions to perform the method of any one of claims 1-5.
CN201910199229.5A 2019-03-15 2019-03-15 Operating environment switching method and operating environment switching device Active CN110046094B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910199229.5A CN110046094B (en) 2019-03-15 2019-03-15 Operating environment switching method and operating environment switching device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910199229.5A CN110046094B (en) 2019-03-15 2019-03-15 Operating environment switching method and operating environment switching device

Publications (2)

Publication Number Publication Date
CN110046094A CN110046094A (en) 2019-07-23
CN110046094B true CN110046094B (en) 2021-01-15

Family

ID=67273780

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910199229.5A Active CN110046094B (en) 2019-03-15 2019-03-15 Operating environment switching method and operating environment switching device

Country Status (1)

Country Link
CN (1) CN110046094B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110442397A (en) * 2019-08-05 2019-11-12 西安瑜乐文化科技股份有限公司 A kind of configuration surroundings switching method and device
CN111090452B (en) * 2019-11-11 2023-04-28 福建天泉教育科技有限公司 Service environment switching method and computer readable storage medium
CN112416776B (en) * 2020-11-24 2022-12-13 天津五八到家货运服务有限公司 Selection method and device of operating environment, test equipment and storage medium
CN112486389A (en) * 2020-11-30 2021-03-12 维沃移动通信有限公司 Configuration file uploading method and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107203440A (en) * 2017-05-27 2017-09-26 郑州云海信息技术有限公司 A kind of integration is backed up in realtime disaster tolerance system and building method
CN108664270A (en) * 2018-05-09 2018-10-16 平安普惠企业管理有限公司 Environment dynamic switching method, device, computer equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
Postman高级应用(3):dev qa prod傻傻分不清楚——设置环境变量;李奕锋;《https://blog.csdn.net/qq598535550/article/details/81007419》;20180712;第1-4页 *

Also Published As

Publication number Publication date
CN110046094A (en) 2019-07-23

Similar Documents

Publication Publication Date Title
CN110046094B (en) Operating environment switching method and operating environment switching device
EP3605324A1 (en) Application development method and tool, device, and storage medium thereof
JP6294886B2 (en) Generate native code from intermediate language code for applications
CN107193577B (en) Application starting method and device and intelligent terminal
CN112100072B (en) Static detection method, device, equipment and medium for application program code
CN105468529A (en) Accurate traversal method and apparatus for UI controls of android application
CN103246578A (en) Method and browser for processing collapse of application software
CN104731622B (en) The loading method of a kind of application program, device and mobile terminal
CN106055368A (en) Application updating method and device
CN111708548A (en) Software installation method, device, equipment and storage medium
CN115291946A (en) Hongmong system transplanting method, device, electronic equipment and readable medium
CN104142881A (en) Adaptive defect detecting method and device of application program programming interfaces
US8769498B2 (en) Warning of register and storage area assignment errors
CN105550575A (en) Method and device for obtaining un-exported function address and data structure offset
CN111385661B (en) Method, device, terminal and storage medium for voice control of full screen playing
KR20210046426A (en) Application optimizing method and electronic device supporting the same
CN112596751B (en) Compiling method, terminal, server and storage medium of application program installation package
CN106775608A (en) The implementation method and device of autonomous system process
CN115344268A (en) Multi-platform embedded development environment compiling method and device
CN114020278B (en) Data processing method, device, equipment and storage medium
CN105446788A (en) Information processing method and electronic equipment
CN104572199B (en) The method and apparatus that a kind of No starting item starts
CN114489698A (en) Application program installation method and device
CN111382416B (en) Application program operation identification method and device, terminal equipment and storage medium
CN109284097B (en) Method, device, system and storage medium for realizing complex data analysis

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