Application program deployment method and device
By obtaining the application's dependency toolkit and assigning classification attributes, generating dependency information and compilation mode, the cumbersome compilation and deployment process in the existing technology are solved, and efficient and standardized application deployment is achieved.
Patent Information
- Application Number
- CN202411591339.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-08
- Publication Date
- 2025-02-11
AI Technical Summary
The existing compilation and deployment processes are cumbersome to adapt to new programming languages or frameworks, which affects the efficiency of application deployment and online, and are prone to errors and cannot meet development needs.
By obtaining the application's dependency toolkit at runtime, assigning classification attributes to it, generating dependency information, determining the compilation mode, compiling the application, generating compilation packages, and adjusting the deployment environment based on the dependency information for deployment.
It realizes standard and standardized application deployment, blocks the impact of programming languages and operation frameworks on deployment, simplifies the deployment process, and improves deployment efficiency.
Smart Images

Figure CN119415103A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for deploying an application program. Background Art
[0002] Whether it is the era of physical machines, virtual machines or containers, the deployment of application code always follows a series of processes including application creation, code compilation, and online release. When an application adopts a new programming language or framework, the existing compilation and deployment processes need to be adaptively adjusted to ensure the smooth deployment of the application.
[0003] In the process of implementing the present invention, the inventors found that the prior art has the following problems:
[0004] The adaptation of the existing compilation and deployment process to new programming languages or frameworks makes the application deployment process cumbersome, affects the efficiency of application deployment and is prone to errors, and cannot meet development needs well. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides an application deployment method and device, which realizes standard and normalized deployment of applications, shields the influence of factors such as the application's programming language and operating framework on the deployment and launch, simplifies the deployment process, and improves deployment efficiency.
[0006] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for deploying an application is provided, comprising:
[0007] Acquire a toolkit that is dependent on an application program at runtime, and assign a classification attribute corresponding to the toolkit to the application program;
[0008] Generate dependency information of the application based on the dependency toolkit, determine a compilation mode of the application according to the classification attribute, compile the application according to the compilation mode, and generate a compilation package of the application;
[0009] The deployment environment of the application is adjusted according to the dependency information, and the compiled package of the application is deployed in the adjusted deployment environment.
[0010] Optionally, in response to the dependent toolkit of the application being a web server toolkit, the classification attribute is the first classification, and the compilation mode is the first compilation mode; compiling the application according to the compilation mode, including: pushing a Java-specific plug-in compilation command to the compilation environment of the application, and using the received compilation command to compile the application; adjusting the deployment environment of the application according to the dependency information, including: searching whether the web server toolkit recorded in the dependency information exists in the deployment environment of the application, and in response to the absence of the web server toolkit in the deployment environment, loading the web server toolkit, and deploying the compilation package of the application using the script built into the web server toolkit.
[0011] Optionally, in response to the dependency toolkit of the application being a non-web server toolkit, the classification attribute is the second classification, and the compilation mode is the second compilation mode; compiling the application according to the compilation mode, including: pushing script additional requirements and compilation command additional requirements to the compilation environment of the application, and compiling the application according to the script additional requirements and the compilation command additional requirements; adjusting the deployment environment of the application according to the dependency information, including: searching whether the dependency toolkit recorded in the dependency information exists in the deployment environment of the application, and in response to the absence of the dependency toolkit in the deployment environment, loading the dependency toolkit, and deploying the compilation package of the application using the dependency toolkit and the script attached to the compilation package.
[0012] Optionally, in response to the fact that the application does not require any dependency toolkit when running, the method also includes: defining the classification attribute of the application as a third classification; generating an application compression package by compressing the application in the compilation environment of the application; and then deploying the application by decompressing the program compression package in the deployment environment of the application.
[0013] Optionally, the dependency information records the name and version number of the dependent toolkit of the application; searching whether the web server toolkit recorded in the dependency information exists in the deployment environment of the application, and in response to the absence of the web server toolkit in the deployment environment, loading the web server toolkit, including: searching whether the name and version number of the web server toolkit recorded in the dependency information exists in the deployment environment of the application; in response to the absence of a toolkit with the same name as the web server toolkit in the deployment environment, loading a toolkit with the same name and version number as the web server toolkit; in response to the presence of an alternative toolkit with the same name as the web server toolkit but a different version number in the deployment environment, upgrading the alternative toolkit according to the version number recorded in the dependency information.
[0014] Optionally, the dependency information records the name and version number of the dependency toolkit of the application; searching whether the dependency toolkit recorded in the dependency information exists in the deployment environment of the application, and in response to the absence of the dependency toolkit in the deployment environment, loading the dependency toolkit, including: searching whether the name and version number of the dependency toolkit recorded in the dependency information exists in the deployment environment of the application; in response to the absence of a toolkit with the same name as the dependency toolkit in the deployment environment, loading a toolkit with the same name and version number as the dependency toolkit; in response to the presence of an alternative toolkit with the same name as the dependency toolkit but a different version number in the deployment environment, upgrading the alternative toolkit according to the version number recorded in the dependency information.
[0015] Optionally, after obtaining the dependency toolkit of the application at runtime, the method further includes: verifying the dependency toolkit according to program information corresponding to the application; and in response to a verification failure, issuing a prompt message indicating that the dependency toolkit verification failed.
[0016] According to a second aspect of an embodiment of the present invention, there is provided a device for deploying an application, comprising:
[0017] An application classification module, used to obtain a dependent toolkit of an application at runtime, and assign a classification attribute corresponding to the dependent toolkit to the application;
[0018] An application compilation module, used to generate dependency information of the application based on the dependency toolkit, and determine a compilation mode of the application according to the classification attribute, and compile the application according to the compilation mode to generate a compilation package of the application;
[0019] The application deployment module is used to adjust the deployment environment of the application according to the dependency information, and deploy the compiled package of the application in the adjusted deployment environment.
[0020] Optionally, in response to the dependency toolkit of the application being a web server toolkit, the classification attribute is the first classification, and the compilation mode is the first compilation mode; the application compilation module is further used to: push a Java-specific plug-in compilation command to the compilation environment of the application, and use the received compilation command to compile the application; the application deployment module is further used to: search whether the web server toolkit recorded in the dependency information exists in the deployment environment of the application, and in response to the absence of the web server toolkit in the deployment environment, load the web server toolkit, and use the built-in script of the web server toolkit to deploy the compilation package of the application.
[0021] Optionally, in response to the dependency toolkit of the application being a non-web server toolkit, the classification attribute is the second classification, and the compilation mode is the second compilation mode; the application compilation module is further used to: push script additional requirements and compilation command additional requirements to the compilation environment of the application, and compile the application according to the script additional requirements and the compilation command additional requirements; the application deployment module is further used to: search whether the dependency toolkit recorded in the dependency information exists in the deployment environment of the application, and in response to the absence of the dependency toolkit in the deployment environment, load the dependency toolkit, and deploy the compilation package of the application using the dependency toolkit and the script attached to the compilation package.
[0022] Optionally, in response to the fact that the application does not require any dependency toolkit when running, the deployment device of the application also includes a toolkit-free deployment module, which is used to: define the classification attribute of the application as a third classification; generate an application compression package by compressing the application in the compilation environment of the application; and then deploy the application by decompressing the program compression package in the deployment environment of the application.
[0023] Optionally, the dependency information records the name and version number of the dependent toolkit of the application; the application deployment module is further used to: search whether the name and version number of the web server toolkit recorded in the dependency information exists in the deployment environment of the application; in response to the absence of a toolkit with the same name as the web server toolkit in the deployment environment, load a toolkit with the same name and version number as the web server toolkit; in response to the presence of an alternative toolkit with the same name as the web server toolkit but a different version number in the deployment environment, upgrade the alternative toolkit according to the version number recorded in the dependency information.
[0024] Optionally, the dependency information records the name and version number of the dependency toolkit of the application; the application deployment module is further used to: search whether the name and version number of the dependency toolkit recorded in the dependency information exists in the deployment environment of the application; in response to the absence of a toolkit with the same name as the dependency toolkit in the deployment environment, load a toolkit with the same name and version number as the dependency toolkit; in response to the presence of an alternative toolkit with the same name as the dependency toolkit but a different version number in the deployment environment, upgrade the alternative toolkit according to the version number recorded in the dependency information.
[0025] Optionally, the deployment device of the application also includes a verification module, which is used to: after obtaining the dependency toolkit of the application at runtime, verify the dependency toolkit according to the program information corresponding to the application; in response to a verification failure, issue a prompt message that the dependency toolkit verification failed.
[0026] According to a third aspect of an embodiment of the present invention, there is provided an electronic device for an application program, including:
[0027] one or more processors;
[0028] a storage device for storing one or more programs,
[0029] When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the first aspect of the embodiment of the present invention.
[0030] According to a fourth aspect of an embodiment of the present invention, there is provided a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the method provided by the first aspect of the embodiment of the present invention is implemented.
[0031] According to a fifth aspect of an embodiment of the present invention, there is provided a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method provided in the first aspect of the embodiment of the present invention is implemented.
[0032] An embodiment of the invention has the following advantages or beneficial effects: by obtaining the dependency toolkit of the application at runtime and assigning classification attributes corresponding to the dependency toolkit to the application; generating dependency information of the application based on the dependency toolkit, and determining the compilation mode of the application according to the classification attributes, compiling the application according to the compilation mode, and generating a compilation package of the application; adjusting the deployment environment of the application according to the dependency information, and deploying the compilation package of the application in the adjusted deployment environment. This technical solution implements a standard and standardized deployment of applications, shields the influence of factors such as the application's programming language and operating framework on the deployment and launch, simplifies the deployment process, and improves deployment efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0034] Figure 1 is a schematic diagram of the main process of the method for deploying an application according to an embodiment of the present invention;
[0035] Figure 2 is a schematic diagram of compilation modes corresponding to different classification attributes of an application program according to an embodiment of the present invention;
[0036] Figure 3 is a detailed flow chart of the compilation and deployment of an application program according to an embodiment of the present invention;
[0037] Figure 4 It is a schematic diagram of the entire process of the deployment method of the application program according to an embodiment of the present invention;
[0038] Figure 5 is a schematic diagram of main modules of a deployment device for an application according to an embodiment of the present invention;
[0039] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0040] Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0041] It should be noted that the acquisition, storage and application of user personal information involved in the technical solution of the present disclosure are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0042] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0043] The adaptation of the existing compilation and deployment process to new programming languages or frameworks makes the application deployment process cumbersome, affects the efficiency of application deployment and is prone to errors, and cannot meet development needs well.
[0044] In order to solve the above-mentioned problems existing in the prior art, the present invention proposes a method for deploying an application. Based on the dependency toolkit of the application at runtime, the application is classified, the classification attributes of the application are determined, and then the compilation mode corresponding to the classification attributes is adopted to compile the application. Then, the application is deployed according to the dependency toolkit, thereby realizing a standard and normalized deployment of the application, shielding the influence of factors such as the application's programming language and operating framework on the deployment and launch, simplifying the deployment process, and improving the deployment efficiency.
[0045] In the introduction to the embodiments of the present invention, the terms and their meanings are as follows:
[0046] tomcat: a free, open source web application server;
[0047] golang: an open source programming language that is statically typed, compiled, concurrent, and has built-in garbage collection.
[0048] Shell script: An executable file consisting of shell commands, which integrates some commands into one file to process business logic;
[0049] Maven: Use the Maven tool to compile the source code of the Java project. Maven is a project management tool that allows developers to build, test and deploy Java projects through simple configurations and commands.
[0050] Figure 1 is a schematic diagram of the main process of the method for deploying an application according to an embodiment of the present invention, such as Figure 1 As shown, the application deployment method of the embodiment of the present invention includes the following steps S101 to S103.
[0051] Step S101: Obtain a toolkit that an application depends on during runtime, and assign a classification attribute corresponding to the toolkit to the application.
[0052] Specifically, from the initiation of an application project to its launch, the application mainly goes through three stages: programming development, compilation, and deployment. The embodiments of the present invention take into account that when an application adopts a new programming language or framework, the existing compilation and deployment processes need to be adaptively adjusted, affecting the deployment efficiency of the application. Based on the perspective of the application's dependency on toolkits at runtime, the impact of factors such as programming language and operating framework on deployment is shielded, and the corresponding processes are embedded in the application's development environment, compilation environment, and deployment environment to achieve rapid deployment of the application.
[0053] Specifically, in the development environment of the application, when the developer creates an application project, the development environment will send a request to the developer to obtain the dependency toolkit of the current application at runtime. Specifically, it can be displayed in the development environment in the form of a pop-up window for the developer to select or fill in, or it can send a request to the developer to obtain the dependency toolkit, and the developer adds a comment description of the dependency toolkit at the start or end position of the code. The specific implementation form is not limited. It can be understood that the developer can modify the dependency toolkit during the entire development process. Finally, after the developer completes the code writing task of the application, the development environment assigns the classification attribute corresponding to the dependency toolkit to the application according to the dependency toolkit recently maintained and determined by the developer. The dependency toolkit of the embodiment of the present invention can specifically be a web server toolkit tomcat, or a Java development toolkit jdk, etc.
[0054] According to one embodiment of the present invention, after obtaining the dependency toolkit of the application at runtime, the method further includes: verifying the dependency toolkit based on program information corresponding to the application; and in response to a verification failure, issuing a prompt message indicating that the dependency toolkit verification failed.
[0055] Specifically, considering that the deployment of the application of the embodiment of the present invention is mainly based on the dependency toolkit of the application at runtime, and the dependency toolkit determines the classification attribute of the application, and the classification attribute determines the compilation mode of the application, it is necessary to verify the obtained dependency toolkit. Historical prior knowledge can be used to count the applications that have been developed in the recent period and their corresponding dependency toolkits, build a knowledge base of dependency toolkits, and use the pre-built knowledge base to verify the dependency toolkit of the application obtained this time. Of course, the learning and feature extraction capabilities of the intelligent large model can also be used to evaluate and infer the recommended dependency toolkit based on the code features of the application, and then compare the obtained dependency toolkit with the dependency toolkit recommended by the large model to obtain the verification result. If the verification fails, a prompt message indicating that the dependency toolkit verification failed is issued to prompt the developer to confirm the correctness of the dependency toolkit again.
[0056] Step S102: Generate dependency information of the application based on the dependency toolkit, determine a compilation mode of the application according to the classification attribute, compile the application according to the compilation mode, and generate a compilation package of the application.
[0057] Specifically, based on the dependency toolkit obtained in the application development environment, dependency information recording the dependency toolkit is generated in the application compilation environment, so that the dependency toolkit of the application at runtime is delivered to the deployment environment through the compilation package.
[0058] In addition, the embodiment of the present invention allocates corresponding compilation modes for the classification attributes determined by various dependency toolkits. For example, some applications need to compile compilation packages without start-stop scripts according to their dependency toolkits. The start-stop scripts of the embodiment of the present invention are scripts for starting and stopping applications. Different compilation modes determine that the final compilation packages are also different. Different compilation modes are embedded in the compilation environment of the application in advance. After the classification attributes of the application are determined, the compilation mode corresponding to the classification attributes is triggered to guide developers to compile compilation packages that meet the requirements.
[0059] According to one embodiment of the present invention, in response to the dependent toolkit of the application being a web server toolkit, the classification attribute being the first classification, and the compilation mode being the first compilation mode; compiling the application according to the compilation mode, including: pushing a Java-specific plug-in compilation command to the compilation environment of the application, and using the received compilation command to compile the application.
[0060] According to another embodiment of the present invention, in response to the dependent toolkit of the application being a non-web server toolkit, the classification attribute is the second classification, and the compilation mode is the second compilation mode; compiling the application according to the compilation mode includes: pushing script additional requirements and compilation command additional requirements to the compilation environment of the application, and compiling the application according to the script additional requirements and the compilation command additional requirements.
[0061] Specifically, based on the toolkit dependencies of various applications in the industry at runtime, the embodiments of the present invention explore the commonalities and characteristics of various toolkit dependencies in the compilation environment and the deployment environment, and can classify applications into two categories, namely the first category and the second category. When the application depends on the web server toolkit at runtime, such as tomcat, the classification attribute of the application is the first category, and the embodiment of the present invention uses web_tomcat to represent it; when the application operation does not depend on the web server toolkit, but depends on one or more of the python, jdk, C, C++ toolkits, etc., the classification attribute of the application is the second category, and the embodiment of the present invention uses worker to represent it.
[0062] For the first category web_tomcat, it corresponds to the first compilation mode. When the developer enters the compilation environment, the compilation environment obtains the classification attribute of the application to be compiled. If it is the first category web_tomcat, the first compilation mode embedded in advance is called up, and the Java-specific plug-in compilation command is pushed to the compilation environment, such as the maven compilation command, to recommend the developer to use the maven compilation command to compile the application and compile a war compilation package without the application start and stop scripts.
[0063] For the second category worker, it corresponds to the second compilation mode. When the developer enters the compilation environment, the compilation environment obtains the classification attributes of the current application to be compiled. If it is a second category worker, the pre-embedded second compilation mode is called, and the script additional requirements and compilation command additional requirements are pushed to the compilation environment, prompting the developer to attach a shell script to start and stop the application in the application, and attach a compilation command. That is, the compilation of the second category application requires that the program code must have a shell script and compilation command to start and stop the application. If there is no start and stop shell script and / or compilation command, compilation is not allowed. Only when the code of the application to be compiled contains a shell script and compilation command to start and stop the application, can the compilation be successful and a zip compilation package with a start and stop shell script be generated.
[0064] Step S103: adjusting the deployment environment of the application according to the dependency information, and deploying the compiled package of the application in the adjusted deployment environment.
[0065] Specifically, according to the dependency information generated in the compilation environment, the current deployment environment where the application is located is adaptively adjusted. The embodiment of the present invention pre-embeds the adjustment deployment logic corresponding to different types of dependency information in the deployment environment. It can be understood that different types of dependency information essentially correspond to applications with different classification attributes. For example, the dependency toolkit tomcat corresponds to one type of adjustment deployment logic; the dependency toolkit is not tomcat, but python, jdk, C, C++, etc., which corresponds to another type of adjustment deployment logic. Further, the current deployment environment is adjusted according to the adjustment deployment logic, and finally the compilation package of the application is deployed in the adjusted deployment environment.
[0066] According to one embodiment of the present invention, in response to the dependent toolkit of the application being a web server toolkit, the deployment environment of the application is adjusted according to the dependency information, including: searching whether the web server toolkit recorded in the dependency information exists in the deployment environment of the application; in response to the absence of the web server toolkit in the deployment environment, loading the web server toolkit, and deploying the compiled package of the application using the script built into the web server toolkit.
[0067] Specifically, when the dependent toolkit of the current application is a web server toolkit, that is, the first category web_tomcat, first search in the current deployment environment whether there is a web server toolkit recorded in the dependency information, such as tomcat. If not, obtain the permission to call the web server toolkit based on the dependency information, apply to the resource library to obtain the web server toolkit, and load the obtained web server toolkit into the current deployment environment. Considering that the first category of applications is compiled directly using the provided Java-specific plug-in compilation command, the web server toolkit comes with its own start-stop script, so after loading the web server toolkit, you can directly decompress the compiled package of the application, pull up the application through the built-in start-stop script of the web server toolkit, and realize the deployment and launch of the application.
[0068] According to another embodiment of the present invention, the dependency information records the name and version number of the dependent toolkit of the application; searching whether the web server toolkit recorded in the dependency information exists in the deployment environment of the application, and in response to the absence of the web server toolkit in the deployment environment, loading the web server toolkit, including: searching whether the name and version number of the web server toolkit recorded in the dependency information exists in the deployment environment of the application; in response to the absence of a toolkit with the same name as the web server toolkit in the deployment environment, loading a toolkit with the same name and version number as the web server toolkit; in response to the presence of an alternative toolkit with the same name as the web server toolkit but different version number in the deployment environment, upgrading the alternative toolkit according to the version number recorded in the dependency information.
[0069] Specifically, in some application deployment scenarios, the dependent toolkit that the application depends on when running has specific version requirements. In this case, the dependency information generated according to the acquired dependent toolkit contains not only the name of the dependent toolkit, but also the corresponding version number. Accordingly, the version number also needs to be considered in the adjustment of the deployment environment. First, find out whether there is a name and version number of the web server toolkit in the deployment environment. If no toolkit with the same name as the web server toolkit is found, then apply for a target toolkit with the same name and version number as the web server toolkit in the dependency information from the resource library, and load the acquired target toolkit into the current deployment environment. If a toolkit with the same name as the web server toolkit but a different version number is found, the alternative toolkit is upgraded according to the version number in the dependency information. It can be understood that both offline upgrade and online upgrade are possible. Of course, if there happens to be a toolkit with the same name and version number as the web server toolkit in the dependency information in the current deployment environment, it can be used directly.
[0070] Through the deployment environment adjustment method of the embodiment of the present invention, not only the standardized deployment and launch of the application is realized, but also the on-demand pulling and loading of dependent toolkits and corresponding versions is realized, avoiding the full pre-set storage of various dependent toolkits and all versions in the deployment environment, saving resources of the deployment environment.
[0071] According to another embodiment of the present invention, in response to the dependency toolkit of the application being a non-web server toolkit, the deployment environment of the application is adjusted according to the dependency information, including: searching whether the dependency toolkit recorded in the dependency information exists in the deployment environment of the application; in response to the absence of the dependency toolkit in the deployment environment, loading the dependency toolkit; and deploying the compilation package of the application using the dependency toolkit and the script attached to the compilation package.
[0072] Specifically, when the dependency toolkit of the current application is a non-web server toolkit, that is, the second category worker, first search in the current deployment environment whether there is a dependency toolkit recorded in the dependency information, such as python, jdk, C, C++, etc. If not, obtain the permission to call the dependency toolkit based on the dependency information, apply to the resource library to obtain the dependency toolkit recorded in the dependency information, and load the obtained dependency toolkit into the current deployment environment. Considering that the second category application requires the developer to attach a start-stop script when compiling, after loading the obtained dependency toolkit, unzip the compiled package of the application, use the start-stop script attached to the compiled package to pull up the application, and implement the deployment and launch of the application.
[0073] According to another embodiment of the present invention, the dependency information records the name and version number of the dependency toolkit of the application; searching whether the dependency toolkit recorded in the dependency information exists in the deployment environment of the application, and in response to the absence of the dependency toolkit in the deployment environment, loading the dependency toolkit, including: searching whether the name and version number of the dependency toolkit recorded in the dependency information exists in the deployment environment of the application; in response to the absence of a toolkit with the same name as the dependency toolkit in the deployment environment, loading a toolkit with the same name and version number as the dependency toolkit; in response to the presence of an alternative toolkit with the same name as the dependency toolkit but a different version number in the deployment environment, upgrading the alternative toolkit according to the version number recorded in the dependency information.
[0074] Specifically, similar to the case where the dependency toolkit is a web server toolkit, in some application deployment scenarios, the dependency toolkit that the application depends on when running has specific version requirements. In this case, the dependency information generated according to the acquired dependency toolkit contains not only the name of the dependency toolkit, but also the corresponding version number. Accordingly, the version number also needs to be considered in the adjustment of the deployment environment. First, find out whether the name and version number of the dependency toolkit recorded in the dependency information exist in the deployment environment. If a toolkit with the same name as the dependency toolkit is not found, then apply for a target toolkit with the same name and version number as the dependency toolkit in the dependency information from the resource library, and load the acquired target toolkit into the current deployment environment. If an alternative toolkit with the same name as the dependency toolkit but a different version number is found, the alternative toolkit is upgraded according to the version number in the dependency information. It can be understood that both offline and online upgrades are possible. Of course, if the current deployment environment happens to have a toolkit with the same name and version number as the dependency toolkit in the dependency information, then it can be used directly.
[0075] Through the analysis and explanation of whether the dependency toolkit of the above-mentioned application is a web server toolkit or a non-web server toolkit, it can be known that the embodiment of the present invention focuses on the dependency toolkit of the application and performs standardized operations from the entire process of application development, compilation, and deployment, which not only avoids errors in the deployment process, but also enables the deployment environment to pull and load the dependency toolkit and the corresponding version on demand, avoiding the full pre-set storage of various dependency toolkits and all versions in the deployment environment, saving resources of the deployment environment.
[0076] According to another embodiment of the present invention, in response to the fact that the application does not require any dependency toolkit when running, the method also includes: defining the classification attribute of the application as a third classification; generating an application compression package by compressing the application in the compilation environment of the application; and then deploying the application by decompressing the program compression package in the deployment environment of the application.
[0077] It cannot be ignored that there may be some applications that do not need to rely on any dependency toolkit when running. The embodiment of the present invention defines this type of application as the third category, represented by static_resource, that is, taking into account all applications, the applications are completely divided into three categories, the first category, the second category, and the third category mentioned here. For the third category, since there is no dependency toolkit, the compilation environment and the deployment environment do not need to embed special processes, or embed processes that do not interfere by default. The application is directly compiled and compressed in the compilation environment using relevant commands to generate a zip compressed package of the application, which can also be called a compilation package. Finally, the compressed package can be decompressed to the specified directory in the deployment environment.
[0078] Figure 2 It is a schematic diagram of the compilation modes corresponding to different classification attributes of the application program of the embodiment of the present invention. It can be seen that the existing application programs are mainly divided into three categories, the first category web_tomcat, the second category worker and the third category static_resource, wherein the application program of the first category web_tomcat mainly relies on the web server toolkit, such as tomcat, at runtime, and accordingly, its first compilation mode is to compile the application program using the pushed Java-specific plug-in compilation command without the need to add a start-stop shell script; the application program of the second category worker mainly relies on other non-web server toolkits such as python, golang, jdk at runtime, and accordingly, its second compilation mode requires the developer to add the start-stop shell script and compilation command according to the script additional requirements and the compilation command additional requirements, so as to compile using the compilation command; the embodiment of the present invention regards the application program that does not require any dependency on the toolkit as the third category static_resource, in which case, the start-stop shell script is not involved, and the application program can be directly compressed in the compilation environment using a specific command.
[0079] Figure 3It is a detailed flow chart of the compilation and deployment of the application of the embodiment of the present invention. The three types of applications correspond to three compilation modes, and the corresponding three methods of adjusting the deployment environment. When the application of the second category worker is compiled, the compilation environment checks the program code to be compiled according to the received script additional requirements and compilation command additional requirements, and checks whether there is a shell script for starting and stopping the application in the program code, and whether there is a compilation command. If the start-stop script or compilation command is missing, the compilation fails and the compilation is exited. Only when the program code contains a shell script and a compilation command for starting and stopping the application, can it be compiled smoothly and a zip compilation package with a start-stop shell script is generated; then in the deployment environment, find out whether there is a dependency toolkit recorded in the dependency information. If there is a dependency toolkit, directly decompress the zip compilation package, use the shell script in the package to start the application, and complete the deployment and launch. If there is no dependency toolkit, then load the dependency toolkit first, then decompress the zip package, use the shell script in the package to start the application, and complete the deployment and launch.
[0080] When compiling an application of the first category, web_tomcat, the compilation environment pushes a Java-specific plug-in compilation command, maven, to the developer for selection. The developer compiles the program code of the application according to the maven compilation command to generate a compiled war package without start and stop shell scripts. Then, in the deployment environment, check whether there is a web server tool package tomcat recorded in the dependency information. If so, directly unzip the war compilation package, use the built-in shell script of the tomcat package to start the application, and complete the deployment and online launch. If the web server tool package does not exist, load the tool package first, then unzip the war package, use the built-in shell script of the tomcat package to start the application, and complete the deployment and online launch.
[0081] The third category is static_resource. When an application that does not depend on a toolkit is compiled, the program code of the application is directly compressed in the compilation environment to generate an application compression package. The application is then deployed by unzipping the program compression package to a specified directory in the deployment environment to complete the deployment and go online.
[0082] Figure 4It is a schematic diagram of the entire process of the deployment method of the application of the embodiment of the present invention. The developer of the application first logs in to the application development environment, creates a project of the application in the development environment, and adds the dependency toolkit of the application at runtime. According to the dependency toolkit of the application obtained, the classification attribute of the application is determined. In the compilation stage of the application, the dependency information of the application is generated according to the dependency toolkit, and the program code of the application is compiled according to the compilation mode corresponding to the classification attribute of the application to generate a compilation package. Finally, in the deployment stage of the application, according to the dependency information, it is found whether there is a dependency toolkit in the current deployment environment. If it exists, the compilation package of the application is deployed based on the dependency toolkit, and the application is started. If it does not exist, the dependency toolkit is first retrieved according to the dependency toolkit in the dependency information and loaded in the current deployment environment, and then the compilation package of the application is deployed based on the loaded dependency toolkit, and the application is started to complete the deployment and go online.
[0083] In summary, the embodiment of the present invention classifies applications based on the dependency toolkits of applications at runtime, determines the classification attributes of applications, and then compiles the applications using the compilation mode corresponding to the classification attributes, and then deploys the applications according to the dependency toolkits, thereby realizing a standard and standardized deployment of applications, shielding the impact of factors such as the application's programming language and operating framework on deployment, simplifying the deployment process, and improving deployment efficiency. In addition, the deployment environment's adjustment method of loading dependency toolkits as needed avoids the need to pre-store all kinds of dependency toolkits in the deployment environment, saving resources in the deployment environment.
[0084] Figure 5 Schematic diagram of the main modules of the deployment device of the application according to the embodiment of the present invention. Figure 5 As shown, the application deployment device 500 mainly includes an application classification module 501 , an application compilation module 502 and an application deployment module 503 .
[0085] An application classification module 501 is used to obtain a dependent toolkit of an application at runtime and assign a classification attribute corresponding to the dependent toolkit to the application;
[0086] An application compilation module 502, configured to generate dependency information of the application based on the dependency toolkit, determine a compilation mode of the application according to the classification attribute, compile the application according to the compilation mode, and generate a compilation package of the application;
[0087] The application deployment module 503 is used to adjust the deployment environment of the application according to the dependency information, and deploy the compiled package of the application in the adjusted deployment environment.
[0088] According to one embodiment of the present invention, in response to the dependent toolkit of the application being a web server toolkit, the classification attribute is the first classification, and the compilation mode is the first compilation mode; the application compilation module 502 is further used to: push a Java-specific plug-in compilation command to the compilation environment of the application, and use the received compilation command to compile the application; the application deployment module 503 is further used to: search whether the web server toolkit recorded in the dependency information exists in the deployment environment of the application, and in response to the absence of the web server toolkit in the deployment environment, load the web server toolkit, and use the built-in script of the web server toolkit to deploy the compilation package of the application.
[0089] According to another embodiment of the present invention, in response to the dependency toolkit of the application being a non-web server toolkit, the classification attribute is the second classification, and the compilation mode is the second compilation mode; the application compilation module 502 is further used to: push script additional requirements and compilation command additional requirements to the compilation environment of the application, and compile the application according to the script additional requirements and the compilation command additional requirements; the application deployment module 503 is further used to: search whether the dependency toolkit recorded in the dependency information exists in the deployment environment of the application, and in response to the absence of the dependency toolkit in the deployment environment, load the dependency toolkit, and deploy the compilation package of the application using the dependency toolkit and the script attached to the compilation package.
[0090] According to another embodiment of the present invention, in response to the fact that the application does not require any dependency toolkit when running, the application deployment device 500 also includes a toolkit-free deployment module (not shown in the figure), which is used to: define the classification attribute of the application as a third classification; generate an application compression package by compressing the application in the compilation environment of the application; and then deploy the application by decompressing the program compression package in the deployment environment of the application.
[0091] According to another embodiment of the present invention, the dependency information records the name and version number of the dependent toolkit of the application; the application deployment module 503 is further used to: search whether the name and version number of the web server toolkit recorded in the dependency information exists in the deployment environment of the application; in response to the absence of a toolkit with the same name as the web server toolkit in the deployment environment, load a toolkit with the same name and version number as the web server toolkit; in response to the presence of an alternative toolkit with the same name as the web server toolkit but a different version number in the deployment environment, upgrade the alternative toolkit according to the version number recorded in the dependency information.
[0092] According to another embodiment of the present invention, the dependency information records the name and version number of the dependency toolkit of the application; the application deployment module 503 is further used to: search whether the name and version number of the dependency toolkit recorded in the dependency information exist in the deployment environment of the application; in response to the absence of a toolkit with the same name as the dependency toolkit in the deployment environment, load a toolkit with the same name and version number as the dependency toolkit; in response to the presence of an alternative toolkit with the same name as the dependency toolkit but a different version number in the deployment environment, upgrade the alternative toolkit according to the version number recorded in the dependency information.
[0093] According to another embodiment of the present invention, the deployment device 500 of the application further includes a verification module (not shown in the figure), which is used to: after obtaining the dependency toolkit of the application at runtime, verify the dependency toolkit according to the program information corresponding to the application; in response to a verification failure, issue a prompt message that the verification of the dependency toolkit has failed.
[0094] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention can be applied.
[0095] like Figure 6 As shown, system architecture 600 may include terminal devices 601, 602, 603, network 604 and server 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0096] Users can use terminal devices 601, 602, 603 to interact with server 605 through network 604 to receive or send messages, etc. Various communication client applications, such as deployment applications, etc., can be installed on terminal devices 601, 602, 603 (only as an example).
[0097] The terminal devices 601 , 602 , and 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.
[0098] The server 605 may be a server that provides various services, such as a background management server (only an example) that provides support for applications that users use terminal devices 601, 602, and 603. The background management server may obtain the dependency toolkit of the application at runtime, and assign classification attributes corresponding to the dependency toolkit to the application; generate dependency information of the application based on the dependency toolkit, and determine the compilation mode of the application according to the classification attributes, compile the application according to the compilation mode, and generate a compilation package of the application; adjust the deployment environment of the application according to the dependency information, deploy the compilation package of the application in the adjusted deployment environment, and feed back the processing results (such as deployment results, etc. - only an example) to the terminal device.
[0099] It should be noted that the application deployment method provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, the application deployment device is generally set in the server 605 .
[0100] It should be understood that Figure 6 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0101] Reference below Figure 7 , Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 7 The terminal device or server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0102] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other through a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0103] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.
[0104] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.
[0105] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination thereof.
[0106] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0107] The units involved in the embodiments of the present invention may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes: an application classification module, an application compilation module and an application deployment module.
[0108] Among them, the names of these modules do not constitute a limitation of the modules themselves in some cases. For example, the application classification module can also be described as "a module for obtaining the dependency toolkit of the application at runtime and assigning classification attributes corresponding to the dependency toolkit to the application."
[0109] On the other hand, the present invention also provides a computer-readable medium, which may be included in the device described in the embodiment; or may exist independently without being assembled into the device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by a device, the device includes: obtaining a dependency toolkit of an application at runtime, and assigning a classification attribute corresponding to the dependency toolkit to the application; generating dependency information of the application based on the dependency toolkit, and determining the compilation mode of the application according to the classification attribute, compiling the application according to the compilation mode, and generating a compilation package of the application; adjusting the deployment environment of the application according to the dependency information, and deploying the compilation package of the application in the adjusted deployment environment.
[0110] The technical solution according to the embodiment of the present invention has the following advantages or beneficial effects: by obtaining the dependency toolkit of the application at runtime and assigning classification attributes corresponding to the dependency toolkit to the application; generating dependency information of the application based on the dependency toolkit, and determining the compilation mode of the application according to the classification attributes, compiling the application according to the compilation mode, and generating a compilation package of the application; adjusting the deployment environment of the application according to the dependency information, and deploying the compilation package of the application in the adjusted deployment environment. The technical solution realizes a standard and standardized deployment of the application, shields the influence of factors such as the application's programming language and operating framework on the deployment and launch, simplifies the deployment process, and improves the deployment efficiency.
[0111] The specific implementation methods described herein do not constitute limitations on the scope of protection of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention shall be included in the scope of protection of the present invention.
Claims
1. A method for deploying an application, characterized in that: include: Acquire a toolkit that is dependent on an application program at runtime, and assign a classification attribute corresponding to the toolkit to the application program; Generate dependency information of the application based on the dependency toolkit, determine a compilation mode of the application according to the classification attribute, compile the application according to the compilation mode, and generate a compilation package of the application; The deployment environment of the application is adjusted according to the dependency information, and the compiled package of the application is deployed in the adjusted deployment environment.
2. The method according to claim 1, characterized in that In response to the dependent toolkit of the application being a web server toolkit, the classification attribute being a first classification, and the compilation mode being a first compilation mode; Compiling the application according to the compilation mode includes: Pushing a Java-specific plug-in compilation command to the compilation environment of the application, and using the received compilation command to compile the application; Adjusting the deployment environment of the application according to the dependency information includes: Searching whether the web server toolkit recorded in the dependency information exists in the deployment environment of the application; in response to the absence of the web server toolkit in the deployment environment, loading the web server toolkit, and deploying the compiled package of the application using a script built into the web server toolkit.
3. The method according to claim 1, characterized in that In response to the dependent toolkit of the application being a non-web server toolkit, the classification attribute being a second classification, and the compilation mode being a second compilation mode; Compiling the application according to the compilation mode includes: Pushing the script additional requirements and the compilation command additional requirements to the compilation environment of the application, and compiling the application according to the script additional requirements and the compilation command additional requirements; Adjusting the deployment environment of the application according to the dependency information includes: Searching whether the dependency toolkit recorded in the dependency information exists in the deployment environment of the application; in response to the absence of the dependency toolkit in the deployment environment, loading the dependency toolkit, and deploying the compilation package of the application using the dependency toolkit and the script attached to the compilation package.
4. The method according to claim 1, characterized in that: In response to the application not requiring any dependency toolkit when running, the method further includes: defining the classification attribute of the application as a third classification; The application is compressed in the compilation environment of the application to generate an application compression package; and the application is deployed by decompressing the program compression package in the deployment environment of the application.
5. The method according to claim 2, characterized in that: The dependency information records the name and version number of the toolkit that the application depends on; Searching whether the web server toolkit recorded in the dependency information exists in the deployment environment of the application, and in response to the web server toolkit not being present in the deployment environment, loading the web server toolkit, including: Find out whether the name and version number of the web server toolkit recorded in the dependency information exists in the deployment environment of the application; In response to the absence of a toolkit with a name consistent with the web server toolkit in the deployment environment, loading a toolkit with a name and a version number consistent with the web server toolkit; In response to the presence of an alternative toolkit in the deployment environment having the same name as the web server toolkit but a different version number, the alternative toolkit is upgraded according to the version number recorded in the dependency information.
6. The method according to claim 3, characterized in that The dependency information records the name and version number of the toolkit that the application depends on; Searching whether the dependent toolkit recorded in the dependency information exists in the deployment environment of the application, and in response to the absence of the dependent toolkit in the deployment environment, loading the dependent toolkit, including: Find out whether the name and version number of the dependency toolkit recorded in the dependency information exists in the deployment environment of the application; In response to the absence of a toolkit with the same name as the dependent toolkit in the deployment environment, loading a toolkit with the same name and version number as the dependent toolkit; In response to the presence of an alternative toolkit in the deployment environment having the same name as the dependent toolkit but a different version number, the alternative toolkit is upgraded according to the version number recorded in the dependency information.
7. The method according to claim 1, characterized in that After obtaining the dependent toolkit of the application at runtime, the method further includes: Verifying the dependent toolkit according to program information corresponding to the application program; In response to the verification failure, a prompt message indicating that the verification of the dependent toolkit has failed is issued.
8. A deployment device for an application, characterized in that: include: An application classification module, used to obtain a dependent toolkit of an application at runtime, and assign a classification attribute corresponding to the dependent toolkit to the application; An application compilation module, used to generate dependency information of the application based on the dependency toolkit, and determine a compilation mode of the application according to the classification attribute, and compile the application according to the compilation mode to generate a compilation package of the application; The application deployment module is used to adjust the deployment environment of the application according to the dependency information, and deploy the compiled package of the application in the adjusted deployment environment.
9. A mobile electronic device terminal, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Application service online method and device based on automatic code generation
CN122547363A