Java-based micro-service automatic deployment method

By obtaining and encrypting server accounts, reading configuration files, automatically logging in and executing deployment commands, it solves the problems of low microservice deployment efficiency and high error rate, realizes large-volume automatic deployment, and improves deployment efficiency and security.

CN118535168APending Publication Date: 2024-08-23SHENZHEN LANYOU TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310196648.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-02-23
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

The deployment of existing microservices in complex systems requires a lot of manpower and time, and is limited by the network environment. It cannot achieve automatic deployment in large batches and is prone to errors.

Method used

Obtain and encrypt the login server account, read the local configuration file, automatically log in and upload the deployment file, detect the JDK environment and deployment status, and use ethz.ssh2 to execute the deployment command to achieve automatic deployment.

Benefits of technology

It solves the problem of automatic deployment of microservices under the influence of specific network permissions, reduces manual deployment time and energy, improves deployment efficiency, and avoids errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535168A
    Figure CN118535168A
Patent Text Reader

Abstract

The invention provides a java-based micro-service automatic deployment method, which comprises the following steps of: S1, acquiring a login server account, encrypting a login password, and writing the encrypted password into a local configuration file; s2, reading local configuration files in sequence, and obtaining server information deployed on a large scale and a deployment content set; s3, performing cyclic automatic deployment according to the configuration information set, logging in the server, uploading all deployment files, detecting before single service deployment, and then executing a deployment command; and S4, detecting the states of all services after deployment. A java language is used for reading a local configuration file to identify deployment content, then command interaction with a server is carried out, the purpose of automatic deployment is finally achieved, the defect that java micro-services cannot be automatically deployed in a large scale due to the limitation of a specific network is overcome, large-scale automatic deployment is carried out in a mode of reading the local configuration file through a local EXE tool, and the deployment efficiency is improved. And a lot of time and energy consumed by manual deployment are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of cloud computing, and more specifically to a method for automatic deployment of Java-based microservices. Background Art

[0002] Microservices in Java is a service-oriented architectural style in which applications are built as a collection of multiple different small services rather than a single application. Unlike a single program, microservices allow you to run multiple independent applications at the same time, and these independent applications can be created using different coding or programming languages. For large and complex systems composed of multiple microservices with different deployment and startup methods, a lot of manpower and time are required during the testing and production environment deployment process. In order to achieve high availability or load balancing, the number of background servers in the system often doubles, and the manpower and time for the deployment of the above microservices also doubles.

[0003] Existing microservice deployments are completed through automated construction platforms that pipeline operations from the test environment to the production environment. For customized microservices, manual deployment is often required from testing to operation.

[0004] In addition, the existing automated deployment platform cannot be fully used in certain operating environments restricted by local area networks due to the influence of the network environment. For systems composed of multiple microservices, the use of high availability or load balancing leads to a large number of servers that need to be deployed, which requires manual deployment, consumes a lot of energy and time, and is prone to errors. Summary of the invention

[0005] The technical problem to be solved by the present invention is to provide a method for automatic deployment of Java-based microservices that is not affected by network permissions of a specific operating environment and can be automatically deployed in large quantities, in response to the shortcomings of the above technical solutions.

[0006] The present invention provides a method for automatic deployment of Java microservices, the method comprising the following steps:

[0007] S1, obtain the login server account and encrypt the login password, and then write the encrypted password into the local configuration file;

[0008] S2, read the local configuration files in sequence, and obtain the server information and deployment content set for mass deployment;

[0009] S3, perform cyclic automatic deployment according to the configuration information set, log in to the server and upload all deployment files, and execute the deployment command after testing before a single service deployment;

[0010] S4, detect the status of all services after deployment, and monitor the effect of completing the automatic deployment execution. In the method for automatic deployment based on Java microservices described in the present invention; in the step S2, the configuration file is stored in the same-level directory of the local tool, and the configuration file is written in the format of a predetermined template, wherein the content of the configuration file includes the deployed Java application service, the deployed server IP, the deployed server user, the deployed server password, the program service name, the deployed path and the deployed command, and the deployed Java application service, the deployed server IP, the deployed server user, the deployed server password, the program service name, the deployed path and the deployed command are generated according to the predetermined format to form a set for subsequent execution deployment.

[0011] In the method for automatic deployment of Java microservices described in the present invention; in the step S2, the corresponding fields of all configuration files are split by Java's StringUtils.substringAfterLast, and each group of configurations is encapsulated into a service deployment set List.

[0012] In the method for automatic deployment of Java microservices described in the present invention; in the process of parsing the configuration file in the background in step S2, when the server password field appears, the plain text of the password is decrypted and saved in the service deployment set List so that login can be performed normally.

[0013] In the method for automatic deployment of Java microservices described in the present invention, the detection before the single service deployment in step S3 includes detecting whether the JDK environment is normal. If there is no JDK, the service deployment is stopped and the deployment of the next service is cycled.

[0014] In the method for automatic deployment of Java microservices described in the present invention, the detection before the single service deployment in step S3 also includes detecting whether the service has been deployed on the server. If it has been deployed, the deployment is stopped and the deployment of the next service is cycled to proceed.

[0015] In the method for automatic deployment of Java microservices described in the present invention; the detection before the single service deployment in step S3 also includes detecting whether there is a deployed program package under the server deployment path. If not, uploading the local corresponding program package to the server deployment path. If it exists, continuing to execute the deployment command.

[0016] In the method for automatic deployment of Java microservices described in the present invention; when the three tests in step S3 are met at the same time, the deployment command is started to be executed, and the deployment command of the service is executed through the server command interaction method of ethz.ssh2. After completion, the deployment of the next service of the configuration information set is looped until the deployment of all configuration services is completed.

[0017] In the method for automatic deployment of Java microservices described in the present invention; in the step S1, the encryption is to encrypt the plain text password of the configuration file using the AES encryption method of SecretKeySpec in the Java package.

[0018] The method for automatic deployment based on Java microservices of the present invention uses Java language to read local configuration files to identify deployment content, and then interacts with the server through commands to finally achieve the purpose of automatic deployment, thereby solving the defect that Java microservices cannot be automatically deployed in large quantities due to specific network restrictions. Large-scale automatic deployment is performed by reading local configuration files through local EXE tools, thereby reducing a lot of time and energy consumed by manual deployment. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 It is a flow chart of an embodiment of a method for automatic deployment of Java microservices based on the present invention. DETAILED DESCRIPTION

[0020] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0021] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0022] like Figure 1 , which is a flow chart of an embodiment of a method for automatic deployment of Java microservices according to the present invention. A method for automatic deployment of Java microservices is provided, comprising the following steps:

[0023] In step S1, the login server account is obtained and the login password is encrypted, and the encrypted password is written into the local configuration file; the server login password is encrypted and then written into the local configuration file in order to prevent information leakage, thereby enhancing security.

[0024] In step S2, local configuration files are read in sequence, and server information and deployment content sets for mass deployment are obtained;

[0025] In step S3, cyclic automatic deployment is performed according to the configuration information set, logging into the server and uploading all deployment files, and executing the deployment command after performing a check before a single service deployment;

[0026] In step S4, the status of all services after deployment is detected, and the effect of completing the automatic deployment execution is monitored.

[0027] In one embodiment, in step S2, the configuration file is stored in a directory at the same level as the local tool, and the configuration file is written in the format of a predetermined template, wherein the content of the configuration file includes the deployed java application service, the deployed server ip, the deployed server user, the deployed server password, the program service name, the deployed path and the deployed command, and the deployed java application service, the deployed server ip, the deployed server user, the deployed server password, the program service name, the deployed path and the deployed command are generated into a collection for subsequent execution deployment in accordance with the predetermined format.

[0028] In one embodiment, in step S2, corresponding fields of all configuration files are split by Java's StringUtils.substringAfterLast, and each set of configurations is encapsulated into a service deployment set List.

[0029] In one embodiment, in step S2, when the server password field appears during the background parsing of the configuration file, the plain text of the password is decrypted and saved to the service deployment set List so that the login can be performed normally. The purpose is to facilitate the normal login of the server account.

[0030] The server password of the configuration file must be encrypted by the tool before use. Otherwise, an error message will be displayed when the login operation is performed later, and the login will fail.

[0031] In one embodiment, the detection before a single service deployment in step S3 includes detecting whether the JDK environment is normal. If there is no JDK, the service deployment is stopped and the next service deployment is cycled.

[0032] In one embodiment, the detection before a single service deployment in step S3 also includes detecting whether the service has been deployed on the server. If it has been deployed, the deployment is stopped and the deployment of the next service is cycled to proceed.

[0033] In one embodiment, the detection before a single service deployment in step S3 also includes detecting whether there is a deployed program package under the server deployment path. If not, the local corresponding program package is uploaded to the server deployment path. If it exists, the deployment command continues to be executed.

[0034] Furthermore, the deployment command will be executed only when the above three detection conditions are met at the same time before a single service deployment. If not, the current service deployment will be skipped and the next service deployment will be cycled.

[0035] In one embodiment, when the three tests in step S3 are met at the same time, the deployment command is started, and the deployment command of the service is executed through the server command interaction method of ethz.ssh2. After completion, the deployment of the next service of the configuration information set is looped until all configuration services are deployed. The purpose is to achieve automatic deployment of microservices in large quantities without using servers.

[0036] In one embodiment, in step S1, encryption is performed by using the AES encryption method of SecretKeySpec in the java package to encrypt the plain text password of the configuration file.

[0037] By using the Java language to read the local configuration file to identify the deployment content, and then interacting with the server through commands, the purpose of automatic deployment is finally achieved. The defect that Java microservices cannot be automatically deployed in large quantities due to specific network restrictions is solved. Large-scale automatic deployment is performed by reading local configuration files through local EXE tools, reducing the time and energy consumed by manual deployment.

[0038] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0039] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0040] Therefore, the above is only a preferred specific implementation mode of the present invention, and the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention. The protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A method for automatic deployment of Java microservices, characterized in that: The method comprises the following steps: S1, obtain the login server account and encrypt the login password, and then write the encrypted password into the local configuration file; S2, read the local configuration files in sequence, and obtain the server information and deployment content set for mass deployment; S3, perform cyclic automatic deployment according to the configuration information set, log in to the server and upload all deployment files, and execute the deployment command after testing before a single service deployment; S4, detects the status of all services after deployment and monitors the results of the automatic deployment execution.

2. The method for automatic deployment of Java microservices according to claim 1 is characterized in that: In the step S2, the configuration file is stored in the same-level directory of the local tool, and the configuration file is written according to the format of a predetermined template, wherein the content of the configuration file includes the deployed java application service, the deployed server ip, the deployed server user, the deployed server password, the program service name, the deployed path and the deployed command, and the deployed java application service, the deployed server ip, the deployed server user, the deployed server password, the program service name, the deployed path and the deployed command are generated into a set for subsequent execution deployment according to the predetermined format.

3. The method for automatic deployment of Java microservices according to claim 2 is characterized in that: In step S2, the corresponding fields of all configuration files are split by Java's StringUtils.substringAfterLast, and each group of configurations is encapsulated into a service deployment set List.

4. The method for automatic deployment of Java microservices according to claim 3 is characterized in that: In the process of parsing the configuration file in the background in step S2, when the server password field appears, the plain text of the password is decrypted and saved in the service deployment set List so that the login can be performed normally.

5. The method for automatic deployment of Java microservices according to claim 4 is characterized in that: The detection before the single service deployment in step S3 includes detecting whether the JDK environment is normal. If there is no JDK, the service deployment is stopped and the deployment of the next service is cycled.

6. A method for automatic deployment of Java microservices according to claim 5, characterized in that: The detection before the single service deployment in step S3 also includes detecting whether the service has been deployed on the server. If it has been deployed, the deployment is stopped and the deployment of the next service is cycled.

7. The method for automatic deployment of Java microservices according to claim 6 is characterized in that: The detection before the single service deployment in step S3 also includes detecting whether there is a deployed program package under the server deployment path. If not, uploading the local corresponding program package to the server deployment path. If so, continuing to execute the deployment command.

8. The method for automatic deployment of Java microservices according to claim 7 is characterized in that: When the three tests in step S3 are met at the same time, the deployment command is started to be executed, and the deployment command of the service is executed through the server command interaction method of ethz.ssh2. After completion, the deployment of the next service of the configuration information set is looped until the deployment of all configuration services is completed.

9. The method for automatic deployment of Java microservices according to claim 1, characterized in that: In the step S1, the encryption is to encrypt the plain text password of the configuration file using the AES encryption method of SecretKeySpec in the java package.