CN117785227B - Java application publishing method and device - Google Patents
Java application publishing method and device Download PDFInfo
- Publication number
- CN117785227B CN117785227B CN202311785660.0A CN202311785660A CN117785227B CN 117785227 B CN117785227 B CN 117785227B CN 202311785660 A CN202311785660 A CN 202311785660A CN 117785227 B CN117785227 B CN 117785227B
- Authority
- CN
- China
- Prior art keywords
- application
- java application
- java
- jar
- appid
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Landscapes
- Stored Programmes (AREA)
Abstract
The embodiment of the specification provides a Java application publishing method and device, wherein the method comprises the steps of creating a Java application, marking the Java application as a Jar package, uploading the Jar package to a platform, assigning the name of the Jar package to AppJarName, adding an application host to be published, setting JVM parameters in the starting process of the Java application and assigning the JVM parameters to JAVA_OPTS, modifying a file path uploaded to the application host by the Java application and assigning the file path to filePath, registering the assigned parameters AppJarName, JAVA _OPTS and filePath as environment variables, adding a synchronization lock according to AppId, performing serial execution and cycling through the application host to be published, detecting whether jdk is installed or not, if not, automatically installing built jdk, closing an application process according to AppId, creating an application deployment directory according to AppId based on the environment variables, backing up the Jar package, starting the Java application, and detecting the state of the Java application.
Description
Technical Field
The present document relates to the field of computer technologies, and in particular, to a method and an apparatus for publishing a Java application.
Background
With the continuous development of information technology, java applications are widely used in various industries. However, there are some cumbersome and time-consuming steps in the development and release process of Java applications, limiting the quick deployment and update of the applications. In order to solve the problem, the invention provides a method and a device for rapidly publishing Java applications.
At present, the release process of Java application usually needs to manually install jdk, upload jar files to an operation server, log in the server to execute an application starting command, if a plurality of servers need to release, the steps need a great deal of time, and the problems of configuration errors, inconsistent versions and the like are easily caused, so that the stability and updating efficiency of the application are affected.
In summary, the prior art has the problems of many manual operation steps, low automation degree, complicated release of multiple batches of machines, easy error and complex application rollback.
Disclosure of Invention
The invention aims to provide a Java application publishing method and device and aims to solve the problems in the prior art.
The invention provides a Java application publishing method, which comprises the following steps:
Creating a Java application, forming the Java application into a Jar package, uploading the Jar package to a platform, and assigning the name of the application Jar package to AppJarName; adding an application host to be released, setting JVM parameters in the starting process of Java application and assigning the JVM parameters to JAVA_OPTS, modifying a file path uploaded to the application host by the Java application and assigning the file path to filePath;
And adding a synchronous lock according to AppId, under the condition of concurrent release, performing serial execution and circulation to traverse the application host to be released, and executing the following operations of detecting whether jdk is installed, if not, automatically installing built-in jdk, closing an application process according to AppId, creating an application deployment catalog according to AppId based on the environment variable, backing up jar packages, starting Java application, and detecting the state of the Java application.
The invention provides a Java application publishing device, which comprises:
The setting module is used for creating Java application, forming Java application into Jar package, uploading the Jar package to the platform, and assigning the name of the application Jar package to AppJarName; adding an application host to be released, setting JVM parameters in the starting process of Java application and assigning the JVM parameters to JAVA_OPTS, modifying a file path uploaded to the application host by the Java application and assigning the file path to filePath;
And the release module is used for adding a synchronous lock according to AppId, performing serial execution and circulation to traverse the application host to be released under the condition of concurrent release, and executing the following operations of detecting whether jdk is installed, if not, automatically installing built-in jdk, closing an application process according to AppId, creating an application deployment catalog according to AppId based on the environment variable, backing up jar packages, starting Java application and detecting the state of the Java application.
The embodiment of the invention also provides electronic equipment, which comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the computer program realizes the steps of the Java application publishing method when being executed by the processor.
The embodiment of the invention also provides a computer readable storage medium, wherein the computer readable storage medium stores an information transmission implementation program, and the program realizes the steps of the Java application publishing method when being executed by a processor.
By adopting the embodiment of the invention, the automatic release can be realized, the visual interaction is realized, the operation is simple, and the application release and rollback of a plurality of machines can be rapidly completed.
Drawings
For a clearer description of one or more embodiments of the present description or of the solutions of the prior art, the drawings that are necessary for the description of the embodiments or of the prior art will be briefly described, it being apparent that the drawings in the description that follow are only some of the embodiments described in the description, from which, for a person skilled in the art, other drawings can be obtained without inventive faculty.
FIG. 1 is a flow chart of a Java application publishing method of an embodiment of the invention;
FIG. 2 is a specific flow diagram of Java application publishing in accordance with an embodiment of the invention;
FIG. 3 is a diagram of a Java application launch state detection command according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a Java application publishing device according to an embodiment of the present invention;
Fig. 5 is a schematic diagram of an electronic device according to an embodiment of the invention.
Detailed Description
In order to enable a person skilled in the art to better understand the technical solutions in one or more embodiments of the present specification, the technical solutions in one or more embodiments of the present specification will be clearly and completely described below with reference to the drawings in one or more embodiments of the present specification, and it is obvious that the described embodiments are only some embodiments of the present specification, not all embodiments. All other embodiments, which can be made by one or more embodiments of the present disclosure without inventive faculty, are intended to be within the scope of the present disclosure.
Method embodiment
According to an embodiment of the present invention, there is provided a Java application publishing method, and fig. 1 is a flowchart of the Java application publishing method according to the embodiment of the present invention, as shown in fig. 1, where the Java application publishing method according to the embodiment of the present invention specifically includes:
step S101, creating a Java application, forming the Java application into a Jar package, uploading the Jar package to a platform, and assigning an application Jar package name to AppJarName; adding an application host to be released, setting JVM parameters in the starting process of Java application and assigning the JVM parameters to JAVA_OPTS, modifying a file path uploaded to the application host by the Java application and assigning the file path to filePath;
Step S102, adding a synchronous lock according to AppId, under the condition of concurrent release, performing serial execution and circulation to traverse the application host to be released, and executing the following operations of detecting whether jdk is installed, if not, automatically installing built-in jdk, closing an application process according to AppId, creating an application deployment catalog according to AppId based on the environment variable, backing up jar packages, starting Java application, and detecting the state of the Java application.
The detecting the state of the Java application specifically comprises the following steps:
acquiring a process ID according to a mark in a command for starting a Java application;
setting a maximum waiting time, and based on the process ID, polling to check whether the Java application is started or not within the range of the maximum waiting time. The method specifically comprises the following steps:
Judging whether the Java application is started or not according to the starting mark of the jar application log file within the range of the maximum waiting time, if the jar application log file has the starting mark, determining that the Java application is started, exiting the loop detection, if the pid is detected to be absent, determining that the Java application is in error in the starting process, exiting the loop detection, setting the exiting code to be 1, and otherwise, continuing the loop detection until the maximum waiting time is not met.
In addition, in the embodiment of the invention, in the case that the release of the Java application fails or a serious vulnerability exists, the Java application is rolled back to the Java application of the last version. The method specifically comprises the following steps:
Stopping the Java application, acquiring a process ID according to AppId and a mark when the Java application is started, and executing a kill-9pid killing process;
And acquiring a Jar packet of a Java application of a version backed up on the rollback directory, exchanging the Jar packet under the rollback directory with the Jar packet under the lib, starting the Java application, and detecting the state of the Java application.
In summary, the technical scheme of the embodiment of the invention introduces the technologies of automatic release, automatic rollback, version control and the like, thereby realizing the rapid release and update of Java application. These improvements greatly simplify the distribution process, reduce the risk of errors, and increase the efficiency and stability of distribution.
The above technical solutions of the embodiments of the present invention are described in detail below with reference to the accompanying drawings.
And step 1, creating an application, namely filling in application basic information, including application names, application descriptions and the like, and generating unique identifiers, such as UUIDs, for the application. And assign a value to AppId fields;
And step 2, uploading the Jar package, namely automatically compiling the source code of the Java application, playing the Jar package and uploading the Jar package to a platform through an automatic construction tool. Assigning the application Jar package name to AppJarName;
And step 3, selecting a host to be issued, namely adding an application host to be issued, which is generally a Linux server.
And 4, modifying application configuration, namely setting JVM parameters in the starting process of the Java application, assigning the JVM parameters to JAVA_OPTS, modifying a file path uploaded to a host by the application, and assigning the file path to the filePath.
Registering the environment variable, namely registering the assigned parameters as the environment variable so that the subsequent application release process can be referred;
step6, publishing application, as shown in fig. 2, specifically comprises the following steps:
And (3) under the condition of adding a synchronous lock and releasing simultaneously according to AppId, performing serial execution, namely circularly traversing the host to be released in the step (3), and performing the following operations:
1. Detecting whether jdk is installed or not, if not, automatically installing built-in jdk
2. Closing an application process according to AppId, preventing port occupation, and enabling the application to be unable to start
3. An application deployment catalog is created according to AppId, the catalog is $ { filePath }/$ { AppId }
Under the default directory, the following subdirectories are created:
bin,logs,lib,rollback
.zonetmp/logs,.zonetmp/rollback,.zonetmp/bin
Process id for bin directory storage application
Console log for logs storage applications
Lib storage application jar package
Roller ack stores last published application jar packet
Zonetmp/logs store application logs prior to this release
Zonetmp/rollback stores application jar packets prior to this release
Zonetmp/bin stores the application Process id before this release
4. And (5) backing up.
Clear. Zonetmp, move the jar packet of rollback to. Zonetmp/rollback
And (3) moving the logs file to zonetmp/logs, moving the jar packet of the lib to the rollback, and moving the jar packet in the step (2) to the list through sftp.
5. The application is started, and the starting command is as follows:
java-Dapplication.tag=${AppId}${JAVA_OPTS}-jar${filePath}/${AppId}/lib/${AppJarName}
>${filePath}/${AppId}/logs/stdout.log
dapplication.tag= $ { AppId } is a flag bit for the start command to beat
JAVA_OPTS is a dynamic configuration parameter filled in the [ modify JVM configuration ] step
The $ { filePath }/$ { AppId }/lib/$ { AppJarName } is the absolute path of the application jar packet that is uploaded to lib
The $ { filePath }/$ { AppId }/logs/stdout. Log is the application launch output log
Step 7, detecting the state, namely dynamically detecting whether the application is started after the start command is executed, wherein the detection command is shown in fig. 3, and the detection steps are as follows:
According to the mark marked in the starting command, the process id is acquired, and the command is as follows:
pid=$(ps-C java-f--width 1000|grep"$AppId"|grep-v grep|awk'{print$2}')
Setting maximum waiting time, polling to check whether the application is started, and in the maximum waiting time range, firstly starting a mark 'Tomcat started' according to jar application log file "
Judging whether the application is started or not, if the key word exists in the log file, the application is started, exiting the loop detection, if the pid is detected to be absent, indicating that the application is in error in the starting process, exiting the loop detection, and setting an exit code to be 1. Otherwise, the detection is circulated until the maximum waiting time is not met, and the dead circulation is prevented.
And 8, rolling back the application, namely if the application fails to release or a serious vulnerability exists and the last version of application needs to be rolled back, rolling back according to the following mode:
1. Stopping the application, and acquiring a process id according to AppId and a mark marked by application start, wherein the process id acquisition command is as follows:
pid=$(ps-C java-f--width 1000|grep"$AppId"|grep-v grep|awk'{print$2}')
Executing kill-9pid, killing the process
2. And acquiring an application Jar package of the previous version, and backing up the application Jar package of the previous time in the roller ack catalog before each application deployment, so that the Jar package under the roller ack catalog and the Jar package under the lib are interchanged, and then executing the starting application and the state monitoring process in the steps.
By the technical scheme of the embodiment of the invention, the Java application can be rapidly released, and the specific beneficial effects include:
The automatic release and state monitoring reduces the time and workload of manual operation and improves the release efficiency of Java application.
The error risk is reduced, namely, the release details of the bottom layer are hidden, so that the application release personnel only pay attention to the service.
And the flexible rollback mechanism is used for introducing the version control and rollback mechanism, so that the prior version can be quickly rolled back when a problem occurs in the release process, and the controllability of the release of the application is ensured.
Device embodiment 1
According to an embodiment of the present invention, there is provided a Java application publishing device, and fig. 4 is a schematic diagram of the Java application publishing device according to the embodiment of the present invention, as shown in fig. 4, the Java application publishing device according to the embodiment of the present invention specifically includes:
The setting module 40 is used for creating a Java application, forming the Java application into a Jar package, uploading the Jar package to the platform, and assigning the name of the application Jar package to AppJarName; adding an application host to be released, setting JVM parameters in the starting process of Java application and assigning the JVM parameters to JAVA_OPTS, modifying a file path uploaded to the application host by the Java application and assigning the file path to filePath;
And the release module 42 is used for adding a synchronous lock according to AppId, performing serial execution and circulation to traverse the application host to be released under the condition of concurrent release, and executing the following operations of detecting whether jdk is installed, if not, automatically installing built-in jdk, closing an application process according to AppId, creating an application deployment catalog according to AppId based on the environment variable, backing up jar packages, starting Java application and detecting the state of the Java application. The method is particularly used for:
acquiring a process ID according to a mark in a command for starting a Java application;
Setting a maximum waiting time, and based on the process ID, polling to check whether the Java application is started or not within the range of the maximum waiting time, wherein the method specifically comprises the following steps:
Judging whether the Java application is started or not according to the starting mark of the jar application log file within the range of the maximum waiting time, if the jar application log file has the starting mark, determining that the Java application is started, exiting the loop detection, if the pid is detected to be absent, determining that the Java application is in error in the starting process, exiting the loop detection, setting the exiting code to be 1, and otherwise, continuing the loop detection until the maximum waiting time is not met.
Further comprises:
the rollback module is configured to rollback to a Java application of a previous version in case of failure in release of the Java application or severe vulnerability, and specifically includes:
Stopping the Java application, acquiring a process ID according to AppId and a mark when the Java application is started, and executing a kill-9pid killing process;
And acquiring a Jar packet of a Java application of a version backed up on the rollback directory, exchanging the Jar packet under the rollback directory with the Jar packet under the lib, starting the Java application, and detecting the state of the Java application.
The embodiment of the present invention is an embodiment of a device corresponding to the embodiment of the method, and specific operations of each module may be understood by referring to descriptions of the embodiment of the method, which are not repeated herein.
Device example two
An embodiment of the invention provides an electronic device, as shown in fig. 5, comprising a memory 50, a processor 52 and a computer program stored on the memory 50 and executable on the processor 52, which computer program, when executed by the processor 52, implements the steps as described in the method embodiments.
Device example III
Embodiments of the present invention provide a computer-readable storage medium having stored thereon a program for carrying out information transmission, which when executed by the processor 52, carries out the steps as described in the method embodiments.
The computer readable storage medium of the present embodiment includes, but is not limited to, ROM, RAM, magnetic disk, optical disk, etc.
It should be noted that the above embodiments are merely for illustrating the technical solution of the present invention and not for limiting the same, and although the present invention has been described in detail with reference to the above embodiments, it should be understood by those skilled in the art that the technical solution described in the above embodiments may be modified or some or all of the technical features may be equivalently replaced, and these modifications or substitutions do not make the essence of the corresponding technical solution deviate from the scope of the technical solution of the embodiments of the present invention.
Claims (7)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202311785660.0A CN117785227B (en) | 2023-12-22 | 2023-12-22 | Java application publishing method and device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202311785660.0A CN117785227B (en) | 2023-12-22 | 2023-12-22 | Java application publishing method and device |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN117785227A CN117785227A (en) | 2024-03-29 |
| CN117785227B true CN117785227B (en) | 2025-04-25 |
Family
ID=90379336
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202311785660.0A Active CN117785227B (en) | 2023-12-22 | 2023-12-22 | Java application publishing method and device |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN117785227B (en) |
Citations (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114546357A (en) * | 2022-02-22 | 2022-05-27 | 广州优谷信息技术有限公司 | A release rollback technology based on load balancing mvn |
Family Cites Families (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6999956B2 (en) * | 2000-11-16 | 2006-02-14 | Ward Mullins | Dynamic object-driven database manipulation and mapping system |
| US20070061794A1 (en) * | 2005-09-13 | 2007-03-15 | Mausolf Jeffry R | Method and apparatus for classpath optimization in a Java runtime environment |
| CN108984193A (en) * | 2018-06-21 | 2018-12-11 | 深圳伊泉净品科技有限公司 | Software service dispositions method |
| CN112130892A (en) * | 2020-09-23 | 2020-12-25 | 平安科技(深圳)有限公司 | Product grayscale release method, device, device and storage medium |
| CN114398061A (en) * | 2022-01-14 | 2022-04-26 | 中国建设银行股份有限公司 | Publishing method, device, equipment and storage medium |
-
2023
- 2023-12-22 CN CN202311785660.0A patent/CN117785227B/en active Active
Patent Citations (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114546357A (en) * | 2022-02-22 | 2022-05-27 | 广州优谷信息技术有限公司 | A release rollback technology based on load balancing mvn |
Also Published As
| Publication number | Publication date |
|---|---|
| CN117785227A (en) | 2024-03-29 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US8245217B2 (en) | Management of software and operating system updates required for the process of creating a virtual machine facsimile of an existing physical or virtual machine | |
| US20210216360A1 (en) | Virtual machine migration method and apparatus | |
| US11307839B2 (en) | Updating of container-based applications | |
| US10942724B2 (en) | Release lifecycle management system for multi-node application | |
| KR101574366B1 (en) | Synchronizing virtual machine and application life cycles | |
| JP5663006B2 (en) | System and method for building a runtime environment | |
| US20140208314A1 (en) | Automatically Propagating Updates in a Data Center | |
| US20110138382A1 (en) | System and method for loading resources into a virtual machine | |
| US8112745B2 (en) | Apparatus and method for capabilities verification and restriction of managed applications in an execution environment | |
| US11886902B2 (en) | Physical-to-virtual migration method and apparatus, and storage medium | |
| CN110825399B (en) | Deployment method and device of application program | |
| CN109857514B (en) | Cross-platform, cross-commercial autonomous environment, complex and giant information system hybrid deployment system | |
| CN108664291A (en) | The construction method and device of container group | |
| CN105955805A (en) | Application container transferring method and device | |
| US9389851B1 (en) | System and method for providing consistency between software library repositories | |
| CN111147291A (en) | A service maintenance method and device | |
| CN118484244A (en) | Extensible plug-in system, method, equipment and storage medium | |
| CN117785227B (en) | Java application publishing method and device | |
| US8904396B2 (en) | System and method of general service management | |
| US20120222023A1 (en) | Automatic runtime dependency lookup | |
| CN107229506B (en) | A virtual machine migration method and device | |
| CN114816445A (en) | System platform architecture, function publishing method and device, platform and storage medium | |
| US8924963B2 (en) | In-process intermediary to create virtual processes | |
| CN116069354A (en) | Application program upgrading method, device, equipment and storage medium | |
| US20030009751A1 (en) | System and method for determining the root cause of a failure |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |