Application startup method, device, equipment and storage medium

By registering and distributing warm-up requests to the current version of the application, the port occupation problem during application version updates in the microservice architecture is solved, and smooth startup and smooth service transition is achieved, reducing the impact on user business.

CN118708262BActive Publication Date: 2024-11-19HANGZHOU NEWGRAND TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411179075.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-27
Publication Date
2024-11-19
Estimated Expiration
2044-08-27

AI Technical Summary

Technical Problem

In the microservice architecture, when the application version is updated, port occupancy issues cause the old version of the application to stop, affecting the normal operation of the system. How to achieve smooth startup from the old version to the current version and reduce the impact on user services.

Method used

By obtaining the Servlet container associated with the current version of the application, registering it in the custom container management class, and when the main Servlet container obtains the user request, distributing the warm-up request to the current version of the application for warm-up until the original stops after the service needs are met. Services for versions of the application.

Benefits of technology

It realizes smooth startup of the current version of the application, reduces the impact of application version replacement on user business, and ensures that the system is running normally.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118708262B_ABST
    Figure CN118708262B_ABST
Patent Text Reader

Abstract

The present invention discloses an application startup method, device, equipment and storage medium. The application startup method comprises: in response to a user-initiated program startup command, obtaining a startup mode associated with the program startup command, and when the startup mode is restart, performing class loading of the current version application; obtaining a current version Servlet container associated with the current version application, and registering it in a Servlet version container of a custom container management class; in response to the main Servlet container obtaining a user request, the main Servlet container establishes a relationship with the current version Servlet container in the Servlet version container, extracts a preheating request from the user request and distributes it to the current version application for program preheating; after the preheating of the current version application is completed, the user request is distributed to the current version application for execution, and the request response status is monitored, and when the service requirements are met, the service of the original version application is stopped, thereby achieving a smooth startup of the application.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of microservice technology, and in particular to an application startup method, device, equipment and storage medium. Background Art

[0002] With the popularization of the Internet, microservice architecture has become one of the preferred architectures for Internet application development. Under the microservice architecture, technicians often use the Spring Boot framework to build applications.

[0003] When an application reports an error, the application needs to be repaired and updated. If the current version and the old version of the application are started at the same time on the same machine, the port will be occupied. Therefore, when running the current version of the application, it is usually necessary to stop the service of the old version of the application. Frequent start and stop during the debugging process will affect the normal operation of the system. Therefore, how to achieve smooth startup from the old version to the current version of the application without affecting the user's use of system services has attracted the attention of technicians. Summary of the invention

[0004] The present invention provides an application startup method, device, equipment and storage medium to achieve smooth startup of the current version of the application.

[0005] According to one aspect of the present invention, there is provided a method for starting an application program, comprising:

[0006] In response to a program start command initiated by a user, obtaining a start mode associated with the program start command, and when the start mode is restart, performing class loading of the current version of the application program;

[0007] Obtain the current version Servlet container associated with the current version application, and register the current version Servlet container in the Servlet version container of the custom container management class; the custom container management class includes a Tomcat container, a main Servlet container, and a Servlet version container; the main Servlet container is bound to the Tomcat container; the Servlet version container includes an original version Servlet container and a current version Servlet container;

[0008] In response to the main Servlet container obtaining the user request, the main Servlet container establishes a relationship with the current version Servlet container in the Servlet version container, extracts the preheating request from the user request, and distributes it to the current version application for program preheating;

[0009] When the current version application meets the preheating end condition, the user request is distributed to the current version application for execution, and the request response status is monitored. When the service requirements are met, the service of the original version application is stopped.

[0010] According to another aspect of the present invention, there is provided an application startup device, comprising:

[0011] A class loading module, for, in response to a program startup command initiated by a user, obtaining a startup mode associated with the program startup command, and, when the startup mode is restart, performing class loading of the current version of the application program;

[0012] A container registration module is used to obtain the current version of the Servlet container associated with the current version of the application, and register the current version of the Servlet container in the Servlet version container of the custom container management class; the custom container management class includes a Tomcat container, a main Servlet container and a Servlet version container; the main Servlet container is bound to the Tomcat container; the Servlet version container includes an original version Servlet container and a current version Servlet container;

[0013] A program preheating module is used for, in response to the main Servlet container obtaining a user request, the main Servlet container establishes a relationship with the current version Servlet container in the Servlet version container, extracts the preheating request from the user request, and distributes it to the current version application for program preheating;

[0014] The program startup module is used to distribute the user request to the current version application for execution when the current version application meets the preheating end condition, monitor the request response status, and stop the service of the original version application when the service requirements are met.

[0015] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0016] at least one processor; and

[0017] a memory communicatively connected to the at least one processor; wherein,

[0018] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the application startup method described in any embodiment of the present invention.

[0019] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the application startup method described in any embodiment of the present invention when executed.

[0020] According to another aspect of the present invention, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the application program startup method of any embodiment of the present disclosure is implemented.

[0021] The technical solution of the embodiment of the present invention obtains the current version Servlet container associated with the current version application, and registers the current version Servlet container in the Servlet version container of the custom container management class. After the main Servlet container obtains the user request, the main Servlet container establishes a relationship with the current version Servlet container in the Servlet version container, extracts the preheating request from the user request, and distributes it to the current version application for program preheating. When the current version application meets the preheating end condition, the user request is distributed to the current version application for execution, and the request response status is monitored. When the service requirements are met, the service of the original version application is stopped. By registering the current version Servlet container with the Sevlet version container and preheating the current version application, a smooth startup of the current version application is achieved.

[0022] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0024] Figure 1 is a flowchart of a method for starting an application program provided according to Embodiment 1 of the present invention;

[0025] Figure 2 is a flowchart of a method for starting an application program according to Embodiment 2 of the present invention;

[0026] Figure 3 is a structural diagram of an application startup device provided according to Embodiment 3 of the present invention;

[0027] Figure 4 It is a structural schematic diagram of an electronic device that implements the application program startup method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0028] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0029] 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.

[0030] Embodiment 1

[0031] Figure 1 A flowchart of an application startup method is provided for the first embodiment of the present invention. This embodiment is applicable to the case where the current version of the application is smoothly started when the original version of the application is started. The method can be executed by an application startup device. The application startup device can be implemented in the form of hardware and / or software. The application startup device can be configured in various general-purpose computing devices. Figure 1 As shown, the method includes:

[0032] S110. In response to a program start command initiated by a user, a start mode associated with the program start command is obtained, and when the start mode is restart, a class of the current version of the application is loaded.

[0033] For Internet applications, when errors occur in the program, the original application needs to be repaired and updated. Generally, the process of repairing and updating the program requires stopping external services until the repaired current version of the application is started. However, this method will affect the business. At this time, a method of smooth transition from the original application to the current application is needed to reduce the impact of program repair on user business.

[0034] In the embodiment of the present invention, the current version of the application is convenient for users to call by exposing the program startup command. After the user overwrites the application package that needs to be updated, the built-in program startup command is called, and the restart flag is set in the loader. When the version application responds to the user's program startup command, the startup mode associated with the program startup command is obtained. When the startup mode is restart, the class of the current version of the application is loaded through the class loader.

[0035] Specifically, the built-in program startup command is called, and the restart flag is set on the parent class loader in the two-layer structure class loader. After the application startup command is called, the main class method is run again to start the current version of the application. During the startup process, when the parent class loader in the two-layer structure class loader is used to load the class, if the restart flag is judged to be 1, the child class loader instance of the two-layer structure class loader is recreated, and the current version of the application class is reloaded.

[0036] S120: Obtain the current version of the Servlet container associated with the current version of the application, and register the current version of the Servlet container in the Servlet version container of the custom container management class.

[0037] The custom container management class includes a Tomcat container, a main Servlet container and a Servlet version container; the main Servlet container is bound to the Tomcat container; and the Servlet version container includes an original version Servlet container and a current version Servlet container.

[0038] In the embodiment of the present invention, after class loading is completed, the newly created current version Servlet container is obtained from the newly created Spring container. In order to achieve smooth startup of the current version application, the current version Servlet container is registered in the Servlet version container of the custom container management class.

[0039] Among them, the custom container management class (hereinafter referred to as the NG-Server class) inherits the application context container (GenericWebApplicationContext container) and implements the onRefresh method. In this method, the Spring container is started by calling the onRefresh of the parent class in the GenericWebApplicationContext container. In this method, the Tomcat container is created through TomcatServletWebServerFactory, and after the creation is completed, the Tomcat container is set as a static variable of the NG-Server class. At the same time, a two-layer Servlet container is constructed, including the main Servlet container and the Servlet version container, and the main Servlet container is associated with the Tomcat container.

[0040] After registering the current version of the Servlet container with the Servlet version container of the NG-Server class, a list of Servlet containers of different versions is formed in the Servlet version container, for example, including both the original version Servlet container and the current version Servlet container. After receiving a user request, the main Servlet container bound to the Tomcat container can distribute the user request to different versions of applications for processing by establishing connections with different versions of Servlet containers in the Servlet version container.

[0041] S130. In response to the main Servlet container obtaining the user request, the main Servlet container establishes a relationship with the current version Servlet container in the Servlet version container, extracts the preheating request from the user request, and distributes it to the current version application for program preheating.

[0042] In the embodiment of the present invention, after the main servlet container obtains the user request, the main servlet container establishes a relationship with the current version servlet container in the servlet version container, extracts the preheating request from the user request based on the preheating processing amount, and distributes it to the current version application for program preheating. Specifically, the preheating processing amount is a preset number of user requests for program preheating, which can be a fixed value or a proportion of the total user request amount.

[0043] In a specific example, after the main Servlet container obtains the user request, a user request stack is established in the memory to divert the user request. After the main Servlet container establishes a relationship with the current version Servlet container in the Servlet version container, the user requests in the user request stack can be distributed to the current version application in batches to preheat the program. For example, the first batch distributes 1 user request to the current version application, the second batch distributes 5 user requests to the current version application, and the third batch distributes 10 user requests to the current version application. For another example, the first batch distributes 1% of all user requests to the current version application, the second batch distributes 3% of user requests to the current version application, and the third batch distributes 5% of user requests to the current version application.

[0044] It is worth noting that the response time of the current version application for each batch of preheating user requests needs to be recorded. If the response time is less than the set time threshold, the preheating is determined to be complete. In addition, in order to reduce the impact on user services, the original version application does not stop running during the preheating process of the current version application. In the user request stack, except for the preheating user requests forwarded to the current version application for execution, all other user requests are forwarded to the original version application for processing.

[0045] S140: When the current version application meets the preheating end condition, the user request is distributed to the current version application for execution, and the request response status is monitored. When the service requirements are met, the service of the original version application is stopped.

[0046] In an embodiment of the present invention, when the current version of the application meets the preheating end condition, all user requests are distributed to the current version of the application for execution. At this time, the current version of the application is online, but it is not certain whether it can meet the service requirements, and a period of monitoring is required. Therefore, the service of the original version of the application will not be terminated during the monitoring period. Specifically, the processing status of the current version of the application for user services can be monitored within a set time period, for example, it can include the request processing time and whether an error occurs during the processing process. The service of the original version of the application will only be terminated if it is monitored within the set time that the processing time of the current version of the application for user requests meets the service requirements and no errors occur during the processing process.

[0047] By obtaining the current version of the Servlet container associated with the current version of the application and registering the current version of the Servlet container in the Servlet version container of the custom container management class, after the main Servlet container obtains the user request, the main Servlet container establishes a relationship with the current version of the Servlet container in the Servlet version container, extracts the preheating request from the user request, and distributes it to the current version of the application for program preheating. When the current version of the application meets the preheating end conditions, the user request is distributed to the current version of the application for execution, and the request response status is monitored. When the service requirements are met, the service of the original version of the application is stopped. By registering the current version of the Servlet container with the Sevlet version container and preheating the current version of the application, a smooth startup of the current version of the application is achieved.

[0048] Embodiment 2

[0049] Figure 2 This is a flowchart of an application startup method provided in the second embodiment of the present invention. This embodiment further refines the above embodiment and provides specific steps of responding to a user-initiated program startup command, obtaining the startup mode associated with the program startup command, and loading the class of the current version of the application when the startup mode is restart, and responding to the main Servlet container obtaining the user request, the main Servlet container establishes a relationship with the current version Servlet container in the Servlet version container, extracts the preheating request from the user request, and distributes it to the current version of the application for program preheating. Figure 2 As shown, the method includes:

[0050] S210: In response to a program start command initiated by a user, a restart flag of a parent class loader in a double-layer structure class loader is obtained.

[0051] In the embodiment of the present invention, the current version application is convenient for users to call by exposing the program startup command. After the user overwrites the application package that needs to be updated, the built-in program startup command is called, and the restart flag is set in the loader. When the version application responds to the user-initiated program startup command, the restart flag of the parent class loader in the double-layer structure class loader is obtained.

[0052] The double-layer structure class loader includes the parent class loader (CCTLoader) and the child class loader (SSTLoader), where SSTLoader inherits CCTLoader. CCTLoader automatically sets the class loader of the current thread to CCTLoader at the program startup entry, and automatically creates SSTLoader when CCTLoader is created.

[0053] S220: When the restart flag is 1, create an instance of a subclass loader in a double-layer structure class loader to perform class loading.

[0054] When loading class information, if the restart flag in CCTLoader is obtained, the class loading process is judged whether the class name is the AnnotationConfigServletWebServerApplicationContext class used to create the Tomcat container associated with the current version of the application. If so, the NG-Server class is automatically loaded and returned to extract the Tomcat container as a static variable from the NG-Server class, so that the current version of the application does not need to create a new Tomcat container, and the Spring boot class is seamlessly replaced; if not, SSTLoader is called for class loading. SSTLoader mainly calls the Spring boot class loader in restart mode to load the class.

[0055] In the embodiment of the present invention, when the restart flag is 1, it indicates that the current startup mode is the restart mode, and at this time, an instance of the subclass loader in the double-layer structure class loader is created to perform class loading.

[0056] S230. Obtain the current version of the Servlet container associated with the current version of the application, and register the current version of the Servlet container to the Servlet version container of the custom container management class; the custom container management class includes a Tomcat container, a main Servlet container, and a Servlet version container; the main Servlet container is bound to the Tomcat container; the Servlet version container includes an original version Servlet container and a current version Servlet container.

[0057] S240: In response to the main Servlet container obtaining the user request, a service request stack is established in the memory.

[0058] In the embodiment of the present invention, after the main Servlet container obtains the user request, in order to facilitate the storage and distribution of the user request, a service request stack is established in the memory, and the user request is output to the service request stack.

[0059] S250: The main Servlet container establishes a relationship with the current version Servlet container in the Servlet version container, and distributes the user requests in the request stack to the current version application in batches according to the preheating processing volume for program preheating.

[0060] In the embodiment of the present invention, the Servlet version container includes a Servlet container list, which may include an original version Servlet container and a current version Servlet container. The main Servlet container can distribute user requests to the current version application for processing by establishing a relationship with the current version Servlet container in the Servlet version container.

[0061] Since the current version of the application is in the initial startup phase, the processing efficiency of user requests is relatively low. Therefore, in order to achieve a smooth startup of the current version of the application, the user requests in the request stack are distributed to the current version of the application in batches according to the preheating processing volume for program preheating. For example, the first batch distributes 1 user request to the current version of the application. If the response time to the first batch of user requests is less than 1 second, the second batch distributes 5 user requests to the current version of the application. If the response time of the second batch is still less than 1 second, the third batch distributes 10 user requests to the current version of the application. If the pre-set response time of the three batches of user requests is all less than 1 second, the preheating is completed. After the preheating is completed, all user requests can be distributed to the current version of the application for processing.

[0062] S260: The main Servlet container establishes a relationship with the original version Servlet container in the Servlet version container, and distributes the remaining user requests in the service request stack to the original version application for processing.

[0063] In the embodiment of the present invention, during the preheating process, the current version of the application can process a small number of user requests and cannot meet the service needs of all users. Therefore, during the preheating process of the current version of the application, the main Servlet container establishes a relationship with the original version Servlet container in the Servlet version container, and distributes all user requests in the service request stack except for the user requests required for preheating to the original version of the application for processing, thereby minimizing the impact of the application version replacement on user services.

[0064] S270: When the time taken by the current version application to process each batch of user requests is less than the first duration threshold, determine that the current version application meets the preheating end condition.

[0065] In an embodiment of the present invention, when the time taken by the current version application to process each batch of user requests is less than the first duration threshold, it is determined that the current version application meets the preheating end condition. Exemplarily, during the preheating process, when the time taken by the current version application to process each batch of user requests is less than 1 second, it is determined that the current version application meets the preheating end condition.

[0066] S280. When the current version of the application meets the preheating end conditions, the user request is distributed to the current version of the application for execution, and the request time of the user request within the set time is monitored. If the request time does not exceed the second time threshold and no error request occurs, it is determined that the current version of the application meets the service requirements.

[0067] In an embodiment of the present invention, when the current version application meets the preheating end condition, the user request is distributed to the current version application for execution. Since there may still be some problems in the operation of the current version application, if the problem is serious, it may even be necessary to return to the original version application to process the user request. In order to achieve a smooth transition between the original version application and the current version application, the original version application will not be destroyed immediately after the current version application starts to process user requests in full. The request time of user requests within the set time period will be monitored. If the request time does not exceed the second time period threshold and no erroneous request occurs, it is determined that the current version application meets the service requirements. Exemplarily, the processing of user requests is monitored within 1 hour. If the request time of the current version application for user requests is less than 1 second within 1 hour and no processing errors occur, it is determined that the current version application meets the service requirements.

[0068] S290. Destroy the original version Servlet container in the Servlet version container to stop the service of the original version application.

[0069] In the embodiment of the present invention, if the current version application meets the service requirements, it means that the current version application can provide services to users normally. At this time, the original version Servlet container in the Servlet version container can be destroyed to stop the service of the original version application.

[0070] Optionally, monitoring of the request response status also includes:

[0071] Monitor the request time of the user request within the set time period, and store the user request character string whose request time exceeds the second time period threshold as a timeout request character string in the timeout request list;

[0072] In response to the main Servlet container obtaining the user request, the current request string in the current user request is compared one by one with the timeout request string in the timeout request list;

[0073] If there is a timeout request string in the timeout request list whose similarity with the current request string is higher than the set threshold, the current user request is forwarded to the original version application for processing, and the request time is obtained;

[0074] If the request time does not exceed the second duration threshold, the current version of the application is set to enter protection mode.

[0075] In this optional embodiment, in the process of monitoring the request response status, the request time of the user request within the set time length is monitored. If the request time is greater than the second time length threshold, the user request string whose request time exceeds the second time length threshold is stored in the timeout request list as a timeout request string. And every time the main Servlet container obtains the user request thereafter, the current request string in the current user request is compared one by one with the timeout request string in the timeout request list. If there is a timeout request string in the timeout request list whose similarity with the current request string is higher than the set threshold, the current user request is forwarded to the original version application for processing, and the request time is obtained. If the request time of the original version application for the user request does not exceed the second time length threshold, it indicates that there is a problem with the current version application causing the request time to be too long. At this time, the current version application can be set to enter protection mode to suspend providing services to users.

[0076] Of course, a times threshold may also be set. If the time taken by the current version application to process user requests multiple times is greater than that of the original version application, the current version application is set to enter protection mode.

[0077] When the current version of the application is in protection mode, the main Servlet container will establish a relationship with the original version Servlet container in the Servlet version container. After receiving user requests, the main Servlet container will distribute them to the original version of the application for processing.

[0078] Optionally, monitor the request response status, including:

[0079] Monitor the request status of user requests within a set time period. If an error request occurs in the current version of the application, forward the error request to the original version of the application for processing;

[0080] If the original version application is processed successfully, the current version application is set to enter protection mode.

[0081] In this optional embodiment, during the monitoring of the request response status, the request status of the user request within the set time period is monitored. If an error request occurs in the current version application, the error request is forwarded to the original version application for processing. If the original version application successfully processes the request, it indicates that there is a problem with the current version application that causes the request error, and the current version application is set to enter protection mode to suspend providing services to users.

[0082] Optionally, after setting the current version of the application to enter protected mode, the following is also included:

[0083] In response to the main Servlet container obtaining the user request, the current request string of the current user request is compared with the request string of the error request;

[0084] If the similarity is higher than the set threshold, the current user request is forwarded to the current version of the application for processing as a user request to be verified;

[0085] If the current version of the application successfully processes the user request to be verified for more than a set number of times, the protection mode of the current version of the application is released.

[0086] In this optional embodiment, after the current version of the application is set to enter the protection mode, when the main Servlet container obtains the user request, the current request string of the current user request is first compared with the request string of the error request. If the similarity is higher than the set threshold, the current user request is forwarded to the current version of the application as a user request to be verified for processing. If the current version of the application successfully processes the user request to be verified more than the set number of times, indicating that the error request that failed to be processed for the first time was an accidental factor, the protection mode of the current version of the application is released. If the current version of the application continues to report errors for the user request to be verified, the current version of the application is taken offline.

[0087] The technical solution of the embodiment of the present invention preheats the current version application and monitors the request response status of the current version application within a set time period after the preheating is completed. Only if the request time of the current version application does not exceed the second time threshold and no error request occurs within the set time period, the original version Servlet container in the Servlet version container will be destroyed and the service of the original version application will be stopped, thereby achieving a smooth transition from the original version application to the current version application and reducing the impact of application version switching on user business.

[0088] Embodiment 3

[0089] Figure 3 This is a schematic diagram of the structure of an application startup device provided by Embodiment 3 of the present invention. Figure 3 As shown, the device comprises:

[0090] The class loading module 310 is used to obtain a startup mode associated with the program startup command in response to a user-initiated program startup command, and load the class of the current version of the application program when the startup mode is restart;

[0091] The container registration module 320 is used to obtain the current version Servlet container associated with the current version application, and register the current version Servlet container in the Servlet version container of the custom container management class; the custom container management class includes a Tomcat container, a main Servlet container and a Servlet version container; the main Servlet container is bound to the Tomcat container; the Servlet version container includes an original version Servlet container and a current version Servlet container;

[0092] A program preheating module 330 is used for, in response to the main Servlet container obtaining a user request, the main Servlet container establishes a relationship with the current version Servlet container in the Servlet version container, extracts the preheating request from the user request, and distributes it to the current version application for program preheating;

[0093] The program startup module 340 is used to distribute the user request to the current version application for execution when the current version application meets the preheating end condition, monitor the request response status, and stop the service of the original version application when the service requirements are met.

[0094] The technical solution of the embodiment of the present invention obtains the current version Servlet container associated with the current version application, and registers the current version Servlet container in the Servlet version container of the custom container management class. After the main Servlet container obtains the user request, the main Servlet container establishes a relationship with the current version Servlet container in the Servlet version container, extracts the preheating request from the user request, and distributes it to the current version application for program preheating. When the current version application meets the preheating end condition, the user request is distributed to the current version application for execution, and the request response status is monitored. When the service requirements are met, the service of the original version application is stopped. By registering the current version Servlet container with the Sevlet version container and preheating the current version application, a smooth startup of the current version application is achieved.

[0095] Optionally, the class loading module 310 is specifically used for:

[0096] In response to a program start command initiated by a user, a restart flag of a parent class loader in a double-layer structure class loader is obtained;

[0097] When the restart flag is 1, an instance of a subclass loader in a double-layer structure class loader is created to perform class loading.

[0098] Optionally, the program preheating module 330 is specifically used for:

[0099] In response to the main Servlet container obtaining the user request, a service request stack is established in the memory;

[0100] The main Servlet container establishes a relationship with the current version Servlet container in the Servlet version container, and distributes the user requests in the request stack to the current version application in batches according to the preheating processing amount for program preheating;

[0101] The main Servlet container establishes a relationship with the original version Servlet container in the Servlet version container, and distributes the remaining user requests in the service request stack to the original version application for processing;

[0102] When the time consumed by the current version application to process each batch of user requests is less than the first duration threshold, it is determined that the current version application meets the preheating end condition.

[0103] Optionally, the program startup module 340 includes:

[0104] A request detection module, used to monitor the request time of user requests within a set time period, and if the request time does not exceed a second time period threshold and no error request occurs, it is determined that the current version of the application meets the service requirements;

[0105] The original version Servlet container in the Servlet version container is destroyed to stop the service of the original version application.

[0106] Optionally, the program startup module 340 further includes:

[0107] A timeout list establishment module is used to monitor the request time of user requests within a set time period, and store the user request character string whose request time exceeds a second time period threshold as a timeout request character string in the timeout request list;

[0108] A first string comparison module is used for comparing the current request string in the current user request with the timeout request string in the timeout request list one by one in response to the main Servlet container obtaining the user request;

[0109] The original processing module is used to forward the current user request to the original version application for processing and obtain the request time if there is a timeout request string in the timeout request list whose similarity with the current request string is higher than a set threshold;

[0110] The first protection module is used to set the current version application to enter a protection mode if the request time does not exceed a second duration threshold.

[0111] Optionally, the program startup module 340 further includes:

[0112] An error request processing module is used to monitor the request status of user requests within a set time period. If an error request occurs in the current version of the application, the error request is forwarded to the original version of the application for processing;

[0113] The second protection module is used to set the current version application to enter a protection mode if the original version application is processed successfully.

[0114] Optionally, the program startup module 340 further includes:

[0115] A second string comparison module is used for, after setting the current version of the application to enter the protection mode, in response to the main Servlet container obtaining the user request, comparing the current request string of the current user request with the request string of the error request;

[0116] A request forwarding module, used for forwarding the current user request as a user request to be verified to the current version application for processing if the similarity is higher than a set threshold;

[0117] The protection release module is used to release the protection mode of the current version of the application if the current version of the application successfully processes the user request to be verified for more than a set number of times.

[0118] The application startup device provided in the embodiment of the present invention can execute the application startup method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0119] In the technical solution of the present invention, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0120] Embodiment 4

[0121] According to an embodiment of the present invention, the present invention also provides an electronic device, a readable storage medium and a computer program product.

[0122] Figure 4A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, applicators, blade applicators, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0123] like Figure 4 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.

[0124] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0125] The processor 11 may be a variety of general and / or dedicated processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as an application startup method.

[0126] In some embodiments, the application startup method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the application startup method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the application startup method in any other appropriate manner (e.g., by means of firmware).

[0127] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0128] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or application.

[0129] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, 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 foregoing.

[0130] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0131] The systems and techniques described herein may be implemented in a computing system that includes a backend component (e.g., as a data applier), or a computing system that includes a middleware component (e.g., an application applier), or a computing system that includes a frontend component (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0132] A computing system may include a client and an application server. The client and the application server are generally remote from each other and usually interact through a communication network. The relationship between the client and the application server is generated by computer programs running on corresponding computers and having a client-application server relationship with each other. The application server may be a cloud application server, also known as a cloud computing application server or a cloud host, which is a host product in a cloud computing application system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS applications.

[0133] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0134] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for starting an application, characterized in that: include: In response to a program start command initiated by a user, obtaining a start mode associated with the program start command, and when the start mode is restart, performing class loading of the current version of the application program; Obtain the current version Servlet container associated with the current version application, and register the current version Servlet container in the Servlet version container of the custom container management class; the custom container management class includes a Tomcat container, a main Servlet container, and a Servlet version container; the main Servlet container is bound to the Tomcat container; the Servlet version container includes an original version Servlet container and a current version Servlet container; In response to the main Servlet container obtaining the user request, the main Servlet container establishes a relationship with the current version Servlet container in the Servlet version container, extracts the preheating request from the user request, and distributes it to the current version application for program preheating; If the current version of the application meets the preheating end condition, the user request is distributed to the current version of the application for execution, and the request response status is monitored. If the service requirements are met, the service of the original version of the application is stopped; In response to the main Servlet container obtaining the user request, the main Servlet container establishes a relationship with the current version Servlet container in the Servlet version container, extracts the preheating request from the user request, and distributes it to the current version application for program preheating, including: In response to the main Servlet container obtaining the user request, a service request stack is established in the memory; The main Servlet container establishes a relationship with the current version Servlet container in the Servlet version container, and distributes the user requests in the request stack to the current version application in batches according to the preheating processing amount for program preheating; The main Servlet container establishes a relationship with the original version Servlet container in the Servlet version container, and distributes the remaining user requests in the service request stack to the original version application for processing; When the time consumed by the current version application to process each batch of user requests is less than the first duration threshold, it is determined that the current version application meets the preheating end condition.

2. The method according to claim 1, characterized in that In response to a user initiating a program start command, obtaining a start mode associated with the program start command, and when the start mode is restart, performing class loading of a current version of the application program, including: In response to a program start command initiated by a user, a restart flag of a parent class loader in a double-layer structure class loader is obtained; When the restart flag is 1, an instance of a subclass loader in a double-layer structure class loader is created to perform class loading.

3. The method according to claim 1, characterized in that Monitor the request response status and stop the service of the original version of the application when the service requirements are met, including: Monitor the request time of the user request within the set time period, and if the request time does not exceed the second time period threshold and no error request occurs, determine that the current version of the application meets the service requirement; Destroy the original version Servlet container in the Servlet version container to stop the service of the original version application.

4. The method according to claim 3, characterized in that Monitoring the request response status also includes: Monitor the request time of the user request within the set time period, and store the user request character string whose request time exceeds the second time period threshold as a timeout request character string in the timeout request list; In response to the main Servlet container obtaining the user request, the current request string in the current user request is compared one by one with the timeout request string in the timeout request list; If there is a timeout request string in the timeout request list whose similarity with the current request string is higher than a set threshold, forward the current user request to the original version application for processing, and obtain the request time; If the request time does not exceed the second duration threshold, the current version of the application is set to enter a protection mode.

5. The method according to claim 3, characterized in that: Monitoring the request response status also includes: Monitor the request status of user requests within a set time period, and if an error request occurs in the current version of the application, forward the error request to the original version of the application for processing; If the original version application is processed successfully, the current version application is set to enter protection mode.

6. The method according to claim 5, characterized in that After setting the current version of the application to enter protection mode, it also includes: In response to the main Servlet container obtaining the user request, the current request string of the current user request is compared with the request string of the error request; If the similarity is higher than the set threshold, the current user request is forwarded to the current version of the application for processing as a user request to be verified; If the current version of the application successfully processes the user request to be verified for more than the set number of times, the protection mode of the current version of the application is released.

7. An application startup device, characterized in that: include: A class loading module, for, in response to a program startup command initiated by a user, obtaining a startup mode associated with the program startup command, and, when the startup mode is restart, performing class loading of the current version of the application program; A container registration module is used to obtain the current version of the Servlet container associated with the current version of the application, and register the current version of the Servlet container in the Servlet version container of the custom container management class; the custom container management class includes a Tomcat container, a main Servlet container and a Servlet version container; the main Servlet container is bound to the Tomcat container; the Servlet version container includes an original version Servlet container and a current version Servlet container; A program preheating module is used for, in response to the main Servlet container obtaining a user request, the main Servlet container establishes a relationship with the current version Servlet container in the Servlet version container, extracts the preheating request from the user request, and distributes it to the current version application for program preheating; The program startup module is used to distribute the user request to the current version application for execution when the current version application meets the preheating end condition, monitor the request response status, and stop the service of the original version application when the service requirements are met; Wherein, the program preheating module is specifically used for: In response to the main Servlet container obtaining the user request, a service request stack is established in the memory; The main Servlet container establishes a relationship with the current version Servlet container in the Servlet version container, and distributes the user requests in the request stack to the current version application in batches according to the preheating processing amount for program preheating; The main Servlet container establishes a relationship with the original version Servlet container in the Servlet version container, and distributes the remaining user requests in the service request stack to the original version application for processing; When the time consumed by the current version application to process each batch of user requests is less than the first duration threshold, it is determined that the current version application meets the preheating end condition.

8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the application startup method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the application startup method according to any one of claims 1 to 6 when executed.