Micro-service running method and device, electronic equipment and storage medium

By using unified scripts and image generation to generate target runtime images, the problems of high cost and low efficiency in microservice development are solved, achieving efficient test environment setup and reduced operation and maintenance costs.

CN115454444BActive Publication Date: 2026-07-21JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD
Filing Date
2022-09-23
Publication Date
2026-07-21

Smart Images

  • Figure CN115454444B_ABST
    Figure CN115454444B_ABST
Patent Text Reader

Abstract

The present disclosure provides a micro-service running method and device, electronic equipment and storage medium, and relates to the technical field of computers. The method comprises: obtaining a target script for compiling and running M micro-services, the target script being set according to a unified name and a unified calling address; obtaining source code data for compiling and building N micro-services based on the target script and target configuration parameters; compiling the source code data through a basic compilation image to build the N micro-services; generating a target running image for the N micro-services based on the basic running image and the N micro-services, so as to run and start the N micro-services using the target running image. In this way, when multiple micro-services are developed simultaneously, corresponding compilation images and running images can be automatically generated according to the configuration files of the micro-services, so that a running environment meeting the simultaneous development of multiple micro-services can be obtained, and the construction of a test environment can be efficiently supported, thereby effectively reducing the expenditure of operation and maintenance personnel.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a microservice operation method, apparatus, electronic device, and storage medium. Background Technology

[0002] With the rapid development of computer technology, computer applications are becoming increasingly complex to meet diverse user needs. To ensure efficient application development, developers use microservices to develop or update applications or services. A microservice can be considered a separate project. The core of microservice architecture is to break down a large monolithic application into many small, interconnected microservices, with multiple instances supporting each microservice. Therefore, compiling, building, and deploying multiple microservices consumes significant time and manpower, leading to high maintenance costs.

[0003] In practical applications, since microservices are often interdependent, in the test environment, due to the negligence of developers, after testing a microservice, it is often not deployed back to the standard version, but is still a development version of a certain feature. This causes test failures when testing the features of other microservices, requiring developers to spend a lot of time troubleshooting the test environment. In addition, due to operational cost considerations, it is often impossible to configure multiple test environments, which means that developers often have to wait in line for test environments when testing a certain microservice, which greatly reduces development efficiency.

[0004] It should be noted that the information in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0005] To overcome the problems existing in related technologies, this disclosure provides a microservice running method, apparatus, electronic device and storage medium, so as to at least solve the problems that, when multiple microservices are not considered for compilation, building and running development, the human maintenance cost is high, the test environment for microservices also requires a lot of time to troubleshoot test environment problems, and developers often have to wait in line for the test environment when testing a certain microservice, which greatly reduces the development efficiency.

[0006] This disclosure provides a microservice operation method, which includes:

[0007] Obtain the target scripts used to compile and run M microservices; the target scripts are set according to a unified name and a unified calling address; M is a positive integer greater than 1;

[0008] The source code data for compiling and building N microservices is obtained based on the target script and target configuration parameters; the target configuration parameters are determined according to the configuration information specified by the user for compiling the N microservices, and N is a positive integer not greater than M;

[0009] The source code data is compiled using a base build image to construct the N microservices; the base build image is determined based on the software package used to compile the M microservices.

[0010] Based on the base runtime image and the N microservices, target runtime images are generated for the N microservices, so that the target runtime images can be used to run and start the N microservices respectively; the base runtime image is determined based on the software package that runs the M microservices.

[0011] Optionally, before obtaining the source code data for compiling and building N microservices based on the target script and target configuration parameters, the method further includes:

[0012] Obtain the software packages that the M microservices depend on during compilation and runtime;

[0013] Based on the software package, base build images and base runtime images for the M microservices are generated respectively.

[0014] Optionally, obtaining the target script for compiling and running M microservices includes:

[0015] Based on the scripts used by the M microservices during compilation and runtime, the target compilation script and target runtime script are obtained according to a unified name and a unified call address setting.

[0016] Optionally, obtaining the source code data for compiling and building N microservices based on the target script and target configuration parameters includes:

[0017] Based on the N microservices indicated by the target configuration parameters, the target compilation script is used to pull source code data from a preset code repository for compiling and building the N microservices.

[0018] Optionally, the step of compiling the source code data using a base build image to construct the N microservices includes:

[0019] The source code data is compiled using the target compilation script and the base compilation image to build the installation packages for the N microservices.

[0020] Optionally, after generating the target runtime image for the N microservices based on the base runtime image and the N microservices, the method further includes:

[0021] Based on the N microservices and the target runtime image, determine the initialization configuration corresponding to the N microservices;

[0022] Based on the initialization configuration, the initialization test environment required for the N microservices to run is generated.

[0023] In the initialization test environment, the target script is used to start the N microservices.

[0024] This disclosure provides a microservice runtime device, which includes:

[0025] The first acquisition module is used to acquire target scripts for compiling and running M microservices; the target scripts are set according to a unified name and a unified calling address; M is a positive integer greater than 1;

[0026] The second acquisition module is used to acquire source code data for compiling and building N microservices based on the target script and target configuration parameters; the target configuration parameters are determined according to the configuration information specified by the user for compiling the N microservices, and N is a positive integer not greater than M;

[0027] A build module is used to compile the source code data using a base build image to build the N microservices; the base build image is determined based on the software package used to compile the M microservices.

[0028] The first generation module is used to generate target running images for the N microservices based on the base running image and the N microservices, so as to run and start the N microservices respectively using the target running images; the base running image is determined based on the software package that runs the M microservices.

[0029] Optionally, before obtaining the source code data for compiling and building N microservices based on the target script and target configuration parameters, the apparatus further includes:

[0030] The third acquisition module is used to acquire the software packages that the M microservices depend on during compilation and runtime;

[0031] The second generation module is used to generate basic compilation images and basic runtime images for the M microservices based on the software package.

[0032] Optionally, the first acquisition module is further configured to:

[0033] Based on the scripts used by the M microservices during compilation and runtime, the target compilation script and target runtime script are obtained according to a unified name and a unified call address setting.

[0034] Optionally, the second acquisition module is further configured to:

[0035] Based on the N microservices indicated by the target configuration parameters, the target compilation script is used to pull source code data from a preset code repository for compiling and building the N microservices.

[0036] Optionally, the building module is further configured to:

[0037] The source code data is compiled using the target compilation script and the base compilation image to build the installation packages for the N microservices.

[0038] Optionally, after generating the target runtime image for the N microservices based on the base runtime image and the N microservices, the apparatus further includes:

[0039] The determination module is used to determine the initialization configuration corresponding to the N microservices based on the N microservices and the target running image;

[0040] The third generation module is used to generate the initialization test environment required by the N microservices at runtime based on the initialization configuration;

[0041] The startup module is used to start the N microservices using the target runtime script in the initialization test environment.

[0042] According to one aspect of this disclosure, an electronic device is provided, comprising:

[0043] Processor; and

[0044] Memory for storing the executable instructions of the processor;

[0045] The processor is configured to execute any of the above-described information processing methods by executing the executable instructions.

[0046] According to one aspect of this disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the information processing method described in any of the preceding claims.

[0047] In summary, the microservice running method provided in this disclosure can obtain target scripts for compiling and running M microservices. The target scripts are set according to a unified name and a unified calling address, where M is a positive integer greater than 1. Based on the target scripts and target configuration parameters, source code data for compiling and building N microservices is obtained. The target configuration parameters are determined according to the configuration information specified by the user for compiling N microservices, where N is a positive integer not greater than M. The source code data is compiled using a base compilation image to build N microservices. The base compilation image is determined based on the software package for compiling M microservices. Based on the base running image and the N microservices, a target running image for the N microservices is generated so that the target running image can be used to run and start the N microservices respectively. The base running image is determined based on the software package for running M microservices. In this way, generating target runtime images for N microservices based on the base build image and base runtime image can effectively reduce the dependence on hardware costs. Furthermore, when developing multiple microservices simultaneously, the corresponding build image and runtime image can be automatically generated according to the microservice configuration file, thereby obtaining a runtime environment that can meet the needs of developing multiple microservices at the same time, reducing the time spent troubleshooting test environment issues, and thus efficiently supporting the construction of the test environment, effectively reducing the expenditure of operation and maintenance manpower. Attached Figure Description

[0048] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0049] Figure 1 This is a flowchart illustrating the steps of a microservice operation method provided in an embodiment of this disclosure;

[0050] Figure 2 This is a schematic diagram of the steps for generating a base image provided in an embodiment of this disclosure;

[0051] Figure 3 This is a schematic diagram of the steps for starting a microservice according to an embodiment of the present disclosure;

[0052] Figure 4 This is a schematic flowchart illustrating the steps for generating a target runtime image according to an embodiment of this disclosure;

[0053] Figure 5 This is a block diagram of a microservice running device provided in an embodiment of this disclosure;

[0054] Figure 6This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0055] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this disclosure more comprehensive and complete, and to fully convey the concept of exemplary embodiments to those skilled in the art. The described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a full understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure may be practiced with one or more of these specific details omitted, or other methods, components, apparatus, steps, etc., may be employed. In other instances, well-known technical solutions are not shown or described in detail to avoid obscuring various aspects of this disclosure.

[0056] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0057] The flowchart shown in the attached diagram is merely an illustrative example and does not necessarily include all steps. For example, some steps may be broken down, while others may be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.

[0058] Figure 1 This disclosure provides a microservice operation method, such as... Figure 1 As shown, the method may include:

[0059] Step S101: Obtain the target scripts for compiling and running M microservices; the target scripts are set according to a unified name and a unified calling address; M is a positive integer greater than 1.

[0060] In this embodiment, microservices typically divide a single application into a set of small services that coordinate and cooperate with each other to provide end-user value. Each service runs in its own independent process, communicating with each other using lightweight mechanisms. Each service is built around a specific business function and often needs to be deployed independently to production or near-production environments. Because different microservices have different dependencies during development, the names and directory addresses of the scripts used to compile and run different microservices are usually different. This embodiment allows setting the same name and the same calling address for scripts used to compile and run different microservices. Therefore, a target script for compiling and running M microservices can be obtained, which can have a unified name and a unified calling address.

[0061] Step S102: Obtain source code data for compiling and building N microservices based on the target script and target configuration parameters; the target configuration parameters are determined according to the configuration information specified by the user for compiling the N microservices, where N is a positive integer greater than 1 and N is a positive integer not greater than M.

[0062] In this embodiment of the disclosure, the target configuration parameters can be configuration parameters used to compile N microservices. For example, they can be parameters for obtaining the IP address of the instance, obtaining the secure port for the instance to receive communication, etc., and this disclosure does not limit this. Obtaining the source code data for compiling and building N microservices based on the target script and target configuration parameters can be done by determining the source code data for compiling and building N microservices from a database storing source code data, according to the target script and target configuration parameters.

[0063] Step S103: Compile the source code data using the base compilation image to build the N microservices; the base compilation image is determined based on the software package used to compile the M microservices.

[0064] In this embodiment, the base build image can be obtained by combining software packages that compile M microservices. This base build image may include Java compilers (JavaC), Go compilers, GNU Compiler Collection (Gcc), Python compilers, and third-party dependency packages, etc., and this disclosure does not impose any limitations on this. Compiling the source code data using the base build image to build N microservices can be achieved by using the compilation tools or software in the base build image to compile the source code data, thereby compiling and building the relevant files for N microservices, such as installation packages for N microservices.

[0065] Step S104: Based on the base runtime image and the N microservices, generate target runtime images for the N microservices so that the target runtime images can be used to run and start the N microservices respectively; the base runtime image is determined based on the software package that runs the M microservices.

[0066] In this embodiment, the base runtime image can be obtained by combining software packages that run M microservices. This base runtime image may include runtime environments such as Java, Go, and Python, as well as common software such as MySQL, Kafka, and Etcd, and all stable, unchanging configuration items; this disclosure does not impose any limitations on this. Based on the base runtime image and N microservices, a target runtime image for the N microservices is generated. This can be achieved by using the runtime environment or software in the base runtime image to run the installation packages of the N microservices, generating the target runtime image for the N microservices. Then, the target runtime image can be directly used to run and start the N microservices. Since the target runtime image contains N microservices, a container can also be created based on the target runtime image to run all the N microservices required by the distributed system. In this way, by integrating N microservices into a single container, hardware costs can be significantly reduced.

[0067] In summary, the microservice running method provided in this disclosure can obtain target scripts for compiling and running M microservices. The target scripts are set according to a unified name and a unified calling address, where M is a positive integer greater than 1. Based on the target scripts and target configuration parameters, source code data for compiling and building N microservices is obtained. The target configuration parameters are determined according to the configuration information specified by the user for compiling N microservices, where N is a positive integer not greater than M. The source code data is compiled using a base compilation image to build N microservices. The base compilation image is determined based on the software package for compiling M microservices. Based on the base running image and the N microservices, a target running image for the N microservices is generated so that the target running image can be used to run and start the N microservices respectively. The base running image is determined based on the software package for running M microservices. In this way, generating target runtime images for N microservices based on the base build image and base runtime image can effectively reduce the dependence on hardware costs. Furthermore, when developing multiple microservices simultaneously, the corresponding build image and runtime image can be automatically generated according to the microservice configuration file, thereby obtaining runtime images that can meet the needs of developing multiple microservices at the same time, reducing the time spent troubleshooting test environment issues, thus efficiently supporting the construction of the test environment and effectively reducing the expenditure of operation and maintenance manpower.

[0068] Optionally, in this embodiment of the disclosure, before the above-described operation of obtaining source code data for compiling and building N microservices based on the target script and target configuration parameters, such as... Figure 2 As shown, it may also include:

[0069] Step S201: Obtain the software packages that the M microservices depend on during compilation and runtime.

[0070] In this embodiment of the disclosure, since different microservices depend on different software packages during compilation and runtime, when creating image files for M microservices, it is necessary to obtain the software packages that the M microservices depend on during compilation and runtime. As mentioned above, the software packages that depend on during compilation can include Java compilers (JavaC), Go compilers, GNU compiler suite (Gcc), Python, and other compilation tools, as well as third-party dependency packages. The software packages that depend on runtime can include runtime environments such as Java, Go, and Python, and can also include public software such as MySQL, Kafka, and Etcd.

[0071] Step S202: Generate basic compilation images and basic runtime images for the M microservices based on the software package.

[0072] In this embodiment, a base build image can be generated by combining software packages used to compile M microservices, and a base runtime image can be generated by combining software packages used to run the M microservices. It should be noted that the base build image and the base runtime image can be container (Docker) base images created in a test environment. The purpose of creating a container (Docker) image is twofold: first, to make the compilation and operation of microservices independent of a specific runtime environment, preventing failures due to missing or corrupted dependencies; and second, to accelerate image download time. Both the base build image and the base runtime image can be provided in the form of a Dockerfile.

[0073] Optionally, the operation of obtaining the target script for compiling and running M microservices described above in this embodiment of the disclosure may specifically include:

[0074] Based on the scripts used by the M microservices during compilation and runtime, the target compilation script and target runtime script are obtained according to a unified name and a unified call address setting.

[0075] In this embodiment, since the scripts used by the M microservices during compilation and runtime include compilation and build scripts, microservice runtime dependency initialization scripts, customized configuration files required for microservices to run in a single Docker environment, and start / stop scripts, and the microservice runtime dependency initialization scripts may include the initialization of third-party dependencies such as database creation and startup, Kafka startup, and topic creation, and these scripts are given a unified name and set under a unified calling address, the target compilation script and target runtime script, set with a unified name and a unified calling address, can be obtained based on the scripts used by the M microservices during compilation and runtime. The target compilation script can be a compilation and build script, and the target runtime script can include the microservice runtime dependency initialization scripts and the customized configuration files required for microservices to run in a single Docker environment.

[0076] It should be noted that in practical applications, consistent compilation and build scripts, configuration methods, initialization scripts, and startup scripts can be provided for all microservices that need to be built. Specifically, consistent compilation and build scripts, configuration methods, initialization scripts, and startup scripts can mean setting the names of all scripts to the same name, the input parameters of all scripts to the same input parameters, the calling methods of all scripts to the same calling methods, the return results of all scripts to the same return results, and so on.

[0077] Optionally, in this embodiment of the present disclosure, the operation of obtaining source code data for compiling and building N microservices based on the target script and target configuration parameters may specifically include:

[0078] Based on the N microservices indicated by the target configuration parameters, the target compilation script is used to pull source code data from a preset code repository for compiling and building the N microservices.

[0079] In this embodiment, the number of N microservices to be built can be determined first based on the target configuration parameters. Then, the target compilation script can be used to pull source code data for compiling and building the N microservices from a preset code repository. The preset code repository can be a database that pre-stores source code data for M microservices. The source code data can be the code required to compile and build the microservices. The source code data for different microservices can be different, and the specific content of the source code data can be determined according to the actual application; this disclosure does not impose any limitations on this.

[0080] Optionally, in this embodiment of the disclosure, the operation of compiling the source code data using a base compilation image to build the N microservices may specifically include:

[0081] The source code data is compiled using the target compilation script and the base compilation image to build the installation packages for the N microservices.

[0082] In this embodiment of the disclosure, the source code data can be compiled using a target compilation script based on a compiler included in the base build image, thereby compiling and building an installation package for N microservices. Specifically, within a container, the source code data can be compiled using a target compilation script and a compiler included in the base build image to generate an installation package for N microservices.

[0083] In practical applications, the microservice installation package can be placed in a designated storage database using the git commitID. When the target build script finds that the microservice source code to be compiled corresponds to a new git commitID, the target build script can execute the compilation and build of the microservice source code with that new git commitID, obtain the installation package corresponding to the microservice with that new git commitID, and store the completed installation package in the repository. If the target build script finds that the repository already stores the microservice installation package obtained by building the microservice source code, it can directly obtain that microservice installation package.

[0084] It should be noted that, in this embodiment of the disclosure, the installation packages of the N microservices built can be stored in a specified directory using the target compilation script, for example, in the / export / Package directory of the container image. The generated target runtime image can also be published to a container (Docker) image repository so that the microservice installation packages can be run in a container later using the target runtime image.

[0085] Optionally, in this embodiment of the disclosure, after the above-described operation of generating target runtime images for the N microservices based on the base runtime image and the N microservices, as follows: Figure 3 As shown, it may also include:

[0086] Step S301: Determine the initialization configuration corresponding to the N microservices based on the N microservices and the target running image.

[0087] In this embodiment of the disclosure, the target runtime image can perform startup operations on the installation packages of N microservices, thereby determining the initialization settings required for the N microservices at startup. Specifically, in a single-container (Docker) runtime environment, the target runtime image can be pulled and the container can be started, and the third-party software in the target runtime image, including databases, Kafka, Etcd, etc., can be started to complete the initialization configuration of each software for running N microservices.

[0088] Step S302: Generate the initialization test environment required for the N microservices to run based on the initialization configuration.

[0089] In this embodiment, it may involve traversing N microservices and completing the initialization test environment required for the runtime of each microservice based on the initialization configuration. In practical applications, it may involve traversing N microservices, executing the initialization script of each microservice, and completing the initialization test environment required for the runtime of each microservice.

[0090] Step S303: In the initialization test environment, start the N microservices using the target running script.

[0091] In this embodiment of the disclosure, N microservices can be started separately using a target execution script in an initialization test environment. In practical applications, it is possible to traverse the N microservices, execute the target execution script of each microservice in the initialization test environment, and start the N microservices.

[0092] Example, Figure 4 This is a schematic diagram of a process for generating a target runtime image provided in an embodiment of this disclosure, such as... Figure 4 As shown, step S401: Pull the base compilation image and start the preset container; step S402: Inside the preset container, download the microservice source code; step S403: Inside the preset container, start the compilation image to build the microservice; step S404: Pull the base runtime image and copy the software package; step S405: Create the target runtime image for testing the microservice and publish it.

[0093] In one embodiment, the container used can be Kubernetes, and the container image of the developed microservice application will be deployed to various Kubernetes systems. Different application runtime environments will have different startup parameters, including environment variables. Some of these parameters are relatively simple to configure, while others are more complex. Mapping these parameters to the actual deployment process requires configuring Kubernetes Deployment resources and other files.

[0094] For example, the test environment corresponding to a microservice can contain multiple installation and deployment scripts. These scripts are adapted to support single-container runtime environments. The specific adaptation steps are as follows: First, pull the base runtime image from the container repository and start the container; Second, inside the container, start third-party software, including databases, Kafka, and Etcd, and complete the initialization configuration of each software; Third, traverse all microservices and execute the microservice initialization script to complete the environment initialization required for the microservice to run; Fourth, traverse all microservices and execute the microservice startup script to start the microservice.

[0095] This disclosure, through its embodiments, sets the target scripts used to compile and run M microservices to a unified name and a unified calling address, and generates base build images and base runtime images based on the software packages that the M microservices depend on during compilation and runtime. This allows for the rapid construction of a lightweight testing system for compiling and running N microservices without secondary development. Specifically, the microservice running method provided by this disclosure can automate the deployment of a lightweight testing environment based on a Kubernetes microservice architecture. During microservice development, a unified compilation, build, and runtime configuration scheme can be agreed upon with the automated deployment of the testing environment, facilitating unified scheduling and execution of automated scripts and effectively reducing operational costs. Furthermore, all Kubernetes microservices can be stored within a single container (Docker), effectively reducing hardware costs. Each deployment and restart of the Docker container provides a clean and unpolluted testing system, significantly increasing developer trust in the testing environment and reducing time spent troubleshooting environmental issues. Moreover, during microservice development, a consistent compilation, build, and runtime configuration scheme can be agreed upon with the automated deployment of the testing environment, facilitating unified scheduling and execution of automated scripts and effectively reducing operational costs.

[0096] Figure 5 This is a block diagram of a microservice running device provided in an embodiment of this disclosure, such as... Figure 5 As shown, the device 50 may include:

[0097] The first acquisition module 501 is used to acquire target scripts for compiling and running M microservices; the target scripts are set according to a unified name and a unified calling address; M is a positive integer greater than 1;

[0098] The second acquisition module 502 is used to acquire source code data for compiling and building N microservices based on the target script and target configuration parameters; the target configuration parameters are determined according to the configuration information specified by the user for compiling the N microservices, and N is a positive integer not greater than M;

[0099] Module 503 is used to compile the source code data using a base compilation image to build the N microservices; the base compilation image is determined based on the software package used to compile the M microservices.

[0100] The first generation module 504 is used to generate target running images for the N microservices based on the base running image and the N microservices, so as to run and start the N microservices respectively using the target running images; the base running image is determined based on the software package that runs the M microservices.

[0101] In summary, the microservice runtime device provided in this embodiment can obtain target scripts for compiling and running M microservices. The target scripts are set according to a unified name and a unified calling address, where M is a positive integer greater than 1. Based on the target scripts and target configuration parameters, source code data for compiling and building N microservices is obtained. The target configuration parameters are determined according to the configuration information specified by the user for compiling N microservices, where N is a positive integer not greater than M. The source code data is compiled using a base compilation image to build N microservices. The base compilation image is determined based on the software package for compiling M microservices. Based on the base runtime image and the N microservices, a target runtime image for the N microservices is generated so that the target runtime image can be used to run and start the N microservices respectively. The base runtime image is determined based on the software package for running M microservices. In this way, generating target runtime images for N microservices based on the base build image and base runtime image can effectively reduce the dependence on hardware costs. Furthermore, when developing multiple microservices simultaneously, the corresponding build image and runtime image can be automatically generated according to the microservice configuration file, thereby obtaining runtime images that can meet the needs of developing multiple microservices at the same time, reducing the time spent troubleshooting test environment issues, thus efficiently supporting the construction of the test environment and effectively reducing the expenditure of operation and maintenance manpower.

[0102] Optionally, before obtaining the source code data for compiling and building N microservices based on the target script and target configuration parameters, the device 50 further includes:

[0103] The third acquisition module is used to acquire the software packages that the M microservices depend on during compilation and runtime;

[0104] The second generation module is used to generate basic compilation images and basic runtime images for the M microservices based on the software package.

[0105] Optionally, the first acquisition module 501 is further configured to:

[0106] Based on the scripts used by the M microservices during compilation and runtime, the target compilation script and target runtime script are obtained according to a unified name and a unified call address setting.

[0107] Optionally, the second acquisition module 502 is further configured to:

[0108] Based on the N microservices indicated by the target configuration parameters, the target compilation script is used to pull source code data from a preset code repository for compiling and building the N microservices.

[0109] Optionally, the building module 503 is further configured to:

[0110] The source code data is compiled using the target compilation script and the base compilation image to build the installation packages for the N microservices.

[0111] Optionally, after generating the target runtime image for the N microservices based on the base runtime image and the N microservices, the apparatus 50 further includes:

[0112] The determination module is used to determine the initialization configuration corresponding to the N microservices based on the N microservices and the target running image;

[0113] The third generation module is used to generate the initialization test environment required by the N microservices at runtime based on the initialization configuration;

[0114] The startup module is used to start the N microservices using the target runtime script in the initialization test environment.

[0115] Exemplary embodiments of this disclosure also provide a computer-readable storage medium that can be implemented as a program product including program code, which, when run on an electronic device, causes the electronic device to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure. In one embodiment, the program product can be implemented as a portable compact disc read-only memory (CD-ROM) including program code and can run on an electronic device, such as a personal computer. However, the program product of this disclosure is not limited thereto. In this document, the readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0116] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0117] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.

[0118] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0119] Program code for performing the operations of this disclosure can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing devices can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0120] Exemplary embodiments of this disclosure also provide an electronic device, which may be a backend server for an item storage terminal. References below... Figure 6 This electronic device will be described. It should be understood that... Figure 6 The electronic device 600 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.

[0121] like Figure 6 As shown, the electronic device 600 is presented in the form of a general-purpose computing device. The components of the electronic device 600 may include, but are not limited to: at least one processing unit 610, at least one storage unit 620, and a bus 630 connecting different system components (including storage unit 620 and processing unit 610).

[0122] The storage unit stores program code, which can be executed by the processing unit 610, causing the processing unit 610 to perform the steps described in the "Exemplary Methods" section above according to various exemplary embodiments of this disclosure. For example, processing unit 610 can execute the following steps: Step S101: Obtain a target script for compiling and running M microservices; the target script is set according to a unified name and a unified calling address; M is a positive integer greater than 1; Step S102: Obtain source code data for compiling and building N microservices based on the target script and target configuration parameters; the target configuration parameters are determined according to the configuration information specified by the user for compiling the N microservices, and N is a positive integer not greater than M; Step S103: Compile the source code data using a base compilation image to build the N microservices; the base compilation image is determined based on the software package for compiling the M microservices; Step S104: Generate a target running image for the N microservices based on the base running image and the N microservices, so that the target running image can be used to run and start the N microservices respectively; the base running image is determined based on the software package for running the M microservices.

[0123] Storage unit 620 may include volatile storage units, such as random access memory (RAM) 621 and / or cache memory 622, and may further include read-only memory (ROM) 623.

[0124] Storage unit 620 may also include a program / utility 624 having a set (at least one) of program modules 625, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.

[0125] Bus 630 may include a data bus, an address bus, and a control bus.

[0126] Electronic device 600 can also communicate with one or more external devices 700 (e.g., keyboards, pointing devices, Bluetooth devices, etc.) via input / output (I / O) interface 640. Electronic device 600 can also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via network adapter 650. As shown, network adapter 650 communicates with other modules of electronic device 600 via bus 630. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0127] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to exemplary embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0128] Those skilled in the art will understand that various aspects of this disclosure can be implemented as systems, methods, or program products. Therefore, various aspects of this disclosure can be embodied in entirely hardware implementations, entirely software implementations (including firmware, microcode, etc.), or implementations combining hardware and software aspects, collectively referred to herein as “circuit,” “module,” or “system.” Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.

[0129] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is defined only by the appended claims.

Claims

1. A microservice operation method, characterized in that, The method includes: Obtain the target scripts used to compile and run M microservices; the target scripts are set according to a unified name and a unified calling address; M is a positive integer greater than 1; The source code data for compiling and building N microservices is obtained based on the target script and target configuration parameters; the target configuration parameters are determined according to the configuration information specified by the user for compiling the N microservices, and N is a positive integer not greater than M; The source code data is compiled using a base build image to construct the N microservices; the base build image is determined based on the software package used to compile the M microservices. Based on the base runtime image and the N microservices, target runtime images are generated for the N microservices, so that a container can be created using the target runtime image to run and start the N microservices respectively; the base runtime image is determined based on the software package that runs the M microservices.

2. The method according to claim 1, characterized in that, Before obtaining the source code data for compiling and building N microservices based on the target script and target configuration parameters, the method further includes: Obtain the software packages that the M microservices depend on during compilation and runtime; Based on the software package, the base compilation image and the base runtime image for the M microservices are generated respectively.

3. The method according to claim 2, characterized in that, The process of obtaining the target script for compiling and running M microservices includes: Based on the scripts used by the M microservices during compilation and runtime, the target compilation script and target runtime script are obtained according to a unified name and a unified call address setting.

4. The method according to claim 3, characterized in that, The process of obtaining source code data for compiling and building N microservices based on the target script and target configuration parameters includes: Based on the N microservices indicated by the target configuration parameters, the target compilation script is used to pull source code data from a preset code repository for compiling and building the N microservices.

5. The method according to claim 3, characterized in that, The process of compiling the source code data using a base build image to construct the N microservices includes: The source code data is compiled using the target compilation script and the base compilation image to build the installation packages for the N microservices.

6. The method according to claim 3, characterized in that, After generating the target runtime image for the N microservices based on the base runtime image and the N microservices, the process further includes: Based on the N microservices and the target runtime image, determine the initialization configuration corresponding to the N microservices; Based on the initialization configuration, the initialization test environment required for the N microservices to run is generated. In the initialization test environment, the target script is used to start the N microservices.

7. A microservice runtime device, characterized in that, The device includes: The first acquisition module is used to acquire target scripts for compiling and running M microservices; the target scripts are set according to a unified name and a unified calling address; M is a positive integer greater than 1; The second acquisition module is used to acquire source code data for compiling and building N microservices based on the target script and target configuration parameters; the target configuration parameters are determined according to the configuration information specified by the user for compiling the N microservices, and N is a positive integer not greater than M; A build module is used to compile the source code data using a base build image to build the N microservices; the base build image is determined based on the software package used to compile the M microservices. The first generation module is used to generate target running images for the N microservices based on the base running image and the N microservices, so as to create a container using the target running image to run and start the N microservices respectively; the base running image is determined based on the software package that runs the M microservices.

8. The apparatus according to claim 7, characterized in that, Before obtaining the source code data for compiling and building N microservices based on the target script and target configuration parameters, the device further includes: The third acquisition module is used to acquire the software packages that the M microservices depend on during compilation and runtime; The second generation module is used to generate basic compilation images and basic runtime images for the M microservices based on the software package.

9. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to execute the microservice operation method according to any one of claims 1 to 6 by executing the executable instructions.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the microservice operation method according to any one of claims 1 to 6.