CN111381932B - Method, device, electronic equipment and storage medium for triggering application program change - Google Patents

Method, device, electronic equipment and storage medium for triggering application program change Download PDF

Info

Publication number
CN111381932B
CN111381932B CN202010153088.6A CN202010153088A CN111381932B CN 111381932 B CN111381932 B CN 111381932B CN 202010153088 A CN202010153088 A CN 202010153088A CN 111381932 B CN111381932 B CN 111381932B
Authority
CN
China
Prior art keywords
configuration information
application program
application
currently executed
change
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
Application number
CN202010153088.6A
Other languages
Chinese (zh)
Other versions
CN111381932A (en
Inventor
高波涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Mobile Communications Group Co Ltd
MIGU Culture Technology Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
MIGU Culture Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by China Mobile Communications Group Co Ltd, MIGU Culture Technology Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN202010153088.6A priority Critical patent/CN111381932B/en
Publication of CN111381932A publication Critical patent/CN111381932A/en
Application granted granted Critical
Publication of CN111381932B publication Critical patent/CN111381932B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45575Starting, stopping, suspending or resuming virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45591Monitoring or debugging support

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Quality & Reliability (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the invention provides a method, a device, electronic equipment and a storage medium for triggering application program change, which comprise the following steps: monitoring that the configuration information of the application program changes, and acquiring the changed configuration information of the application program from a configuration file corresponding to the application program; and determining that the configuration information of the changed application program is inconsistent with the configuration information currently executed by the application program, and triggering the application program to restart so as to execute the configuration information after the change. According to the method, the device, the electronic equipment and the storage medium for triggering application program change, provided by the embodiment of the invention, through real-time monitoring of the change of the configuration information of the application program, the problem that the configuration information after the change is different from the configuration information currently executed by the application program is rapidly found, so that the application program is triggered to restart, the change of the application program is realized, and the efficiency of the application program change is improved.

Description

触发应用程序更改的方法、装置、电子设备及存储介质Methods, devices, electronic devices and storage media for triggering application changes

技术领域Technical field

本发明涉及计算机技术领域,尤其涉及一种触发应用程序更改的方法、装置、电子设备及存储介质。The present invention relates to the field of computer technology, and in particular, to a method, device, electronic device and storage medium for triggering application program modification.

背景技术Background technique

Kubernetes是一个开源的、用于管理云平台中多个主机上的容器化的应用程序,Kubernetes的目标是让部署容器化的应用程序简单并高效,它提供了应用程序部署、规划、更新、维护的一种机制。Kubernetes通过更新应用程序的配置信息以实现对安装在容器中的应用程序的更改。Kubernetes is an open source application used to manage containerized applications on multiple hosts in a cloud platform. The goal of Kubernetes is to make deploying containerized applications simple and efficient. It provides application deployment, planning, updates, and maintenance. a mechanism. Kubernetes implements changes to applications installed in containers by updating the application's configuration information.

ConfigMap是Kubernetes中用于存储通用配置变量的配置文件。它使用户可以将分布式系统中用于不同模块的环境变量统一到一个对象中管理。Kubernetes可通过对ConfigMap的更新来更改容器中的应用程序。ConfigMap is a configuration file used in Kubernetes to store common configuration variables. It allows users to unify environment variables for different modules in a distributed system into one object for management. Kubernetes can change the application in the container through updates to the ConfigMap.

在Kubernetes中,由于容器中的应用程序不会监视配置信息的更改,因此ConfigMap的更新并不必然会导致应用程序所执行配置信息的同步更新。在现有技术中,当配置信息更新后,只有在应用程序重新启动进程时才能加载新的配置信息,或出现新的应用程序被创建而原有的应用程序被终止的状态时才能加载新的配置信息。即,现有技术中存在着更新配置信息后,应用程序在不重启的情况下,仍然执行原有更新前的配置信息的现象,具有更新的配置信息与应用程序当前执行的配置信息不同的问题。In Kubernetes, since the application in the container does not monitor changes in configuration information, updates to the ConfigMap do not necessarily lead to synchronous updates of the configuration information executed by the application. In the prior art, when the configuration information is updated, the new configuration information can only be loaded when the application restarts the process, or when a new application is created and the original application is terminated. Configuration information. That is, in the existing technology, there is a phenomenon that after the configuration information is updated, the application still executes the original configuration information before the update without restarting, and there is a problem that the updated configuration information is different from the configuration information currently executed by the application. .

现有技术中需要通过手动重启应用程序的方法来克服更新的配置信息与应用程序当前执行的配置信息不同的问题。不仅效率低,而且反应不及时。In the prior art, it is necessary to manually restart the application program to overcome the problem that the updated configuration information is different from the configuration information currently executed by the application program. Not only is the efficiency low, but the response is not timely.

发明内容Contents of the invention

本发明实施例提供一种触发应用程序更改的方法、装置、电子设备及存储介质,用以解决现有技术中手动重启应用程序方法执行效率低、反应不及时的缺陷。Embodiments of the present invention provide a method, a device, an electronic device, and a storage medium for triggering application program changes, so as to solve the defects of low execution efficiency and untimely response of the manual restarting application program method in the prior art.

本发明第一方面实施例提供了一种触发应用程序更改的方法,包括:The first embodiment of the present invention provides a method for triggering application changes, including:

监控到应用程序的配置信息发生变动,从所述应用程序所对应的配置文件中获取所述应用程序的变动后配置信息;Monitor changes in the configuration information of the application, and obtain the changed configuration information of the application from the configuration file corresponding to the application;

确定所述应用程序的变动后配置信息与所述应用程序当前执行的配置信息不一致,触发所述应用程序重启以执行变动后配置信息。It is determined that the changed configuration information of the application program is inconsistent with the configuration information currently executed by the application program, and the application program is triggered to restart to execute the changed configuration information.

基于本发明任一实施例,还包括:Based on any embodiment of the present invention, it also includes:

监控到应用程序触发目标事件,获取所述应用程序当前执行的配置信息,存储所述应用程序当前执行的配置信息;其中,所述目标事件为所述应用程序的创建事件或读取事件或更新事件。Monitor that the application triggers a target event, obtain the configuration information currently executed by the application, and store the configuration information currently executed by the application; wherein the target event is a creation event or read event or update of the application event.

基于本发明任一实施例,还包括:Based on any embodiment of the present invention, it also includes:

为所要监控的应用程序的对象设置标注;其中,所述标注包括用于描述应用程序的配置信息是否发生变动的第一字段以及用于保存应用程序当前执行的配置信息的第二字段。Set a label for the object of the application program to be monitored; wherein the label includes a first field used to describe whether the configuration information of the application program has changed and a second field used to save the configuration information currently executed by the application program.

基于本发明任一实施例,所述确定所述应用程序的变动后配置信息与所述应用程序当前执行的配置信息不一致包括:Based on any embodiment of the present invention, determining that the changed configuration information of the application program is inconsistent with the configuration information currently executed by the application program includes:

计算所述应用程序的变动后配置信息的哈希值;Calculate the hash value of the changed configuration information of the application;

计算所述应用程序当前执行的配置信息的哈希值;Calculate a hash value of the configuration information currently executed by the application;

确定所述应用程序的变动后配置信息的哈希值与所述应用程序当前执行的配置信息的哈希值不一致。It is determined that the hash value of the changed configuration information of the application program is inconsistent with the hash value of the configuration information currently executed by the application program.

基于本发明任一实施例,所述监控到应用程序的配置信息发生变动包括:采用Kubernetes中的控制器监控到应用程序的配置信息发生变动。Based on any embodiment of the present invention, monitoring changes in the configuration information of the application program includes: using a controller in Kubernetes to monitor changes in the configuration information of the application program.

基于本发明任一实施例,所述监控到应用程序触发目标事件包括:采用Kubernetes中的控制器监控到应用程序触发目标事件。Based on any embodiment of the present invention, monitoring the application triggering the target event includes: using a controller in Kubernetes to monitor the application triggering the target event.

基于本发明任一实施例,所述存储所述应用程序当前执行的配置信息包括:在应用程序的对象的标注的第二字段中存储所述应用程序当前执行的配置信息。Based on any embodiment of the present invention, storing the configuration information currently executed by the application program includes: storing the configuration information currently executed by the application program in a second field marked on the object of the application program.

本发明第二方面实施例还提供了一种触发应用程序更改的装置,包括:The second embodiment of the present invention also provides a device for triggering application changes, including:

变动后配置信息获取模块,用于监控到应用程序的配置信息发生变动,从所述应用程序所对应的配置文件中获取所述应用程序的变动后配置信息;The post-change configuration information acquisition module is used to monitor changes in the configuration information of the application and obtain the post-change configuration information of the application from the configuration file corresponding to the application;

应用程序重启触发模块,用于确定所述应用程序的变动后配置信息与所述应用程序当前执行的配置信息不一致,触发所述应用程序重启以执行变动后配置信息。The application restart triggering module is configured to determine that the changed configuration information of the application program is inconsistent with the configuration information currently executed by the application program, and trigger the restart of the application program to execute the changed configuration information.

本发明第三方面实施例提供了一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时实现如本发明第一方面实施例所述触发应用程序更改的方法的步骤。A third embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the first aspect of the present invention is implemented. Steps of a method for triggering application changes described in aspect embodiments.

本发明第四方面实施例提供了一种非暂态计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如本发明第一方面实施例所述触发应用程序更改的方法的步骤。The fourth embodiment of the present invention provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the application program modification is triggered as described in the first embodiment of the present invention. steps of the method.

本发明实施例提供的触发应用程序更改的方法、装置、电子设备及存储介质,通过对应用程序配置信息变动的实时监控,迅速发现变动后配置信息与应用程序当前执行的配置信息不同的问题,进而触发应用程序重启,实现应用程序的更改,提高了应用程序更改的效率。The methods, devices, electronic devices and storage media for triggering application changes provided by embodiments of the present invention can quickly detect the problem that the changed configuration information is different from the configuration information currently executed by the application through real-time monitoring of changes in the application configuration information. This in turn triggers application restart, implements application changes, and improves the efficiency of application changes.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the drawings in the following description These are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without exerting creative efforts.

图1为本发明实施例提供的触发应用程序更改的方法的流程图;Figure 1 is a flow chart of a method for triggering application changes provided by an embodiment of the present invention;

图2为本发明另一实施例提供的触发应用程序更改的方法的流程图;Figure 2 is a flow chart of a method for triggering application changes provided by another embodiment of the present invention;

图3为本发明又一实施例提供的触发应用程序更改的方法的流程图;Figure 3 is a flow chart of a method for triggering application changes provided by yet another embodiment of the present invention;

图4为本发明实施例提供的触发应用程序更改的装置的结构图;Figure 4 is a structural diagram of a device for triggering application changes provided by an embodiment of the present invention;

图5示例了一种电子设备的实体结构示意图。Figure 5 illustrates a schematic diagram of the physical structure of an electronic device.

具体实施方式Detailed ways

为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments These are some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative efforts fall within the scope of protection of the present invention.

图1为本发明实施例提供的触发应用程序更改的方法的流程图,如图1所示,本发明实施例提供的触发应用程序更改的方法包括:Figure 1 is a flow chart of a method for triggering application changes provided by an embodiment of the present invention. As shown in Figure 1, the method for triggering application changes provided by an embodiment of the present invention includes:

步骤101、监控到应用程序的配置信息发生变动,从所述应用程序所对应的配置文件中获取所述应用程序的变动后配置信息。Step 101: Monitor changes in the configuration information of the application program, and obtain the changed configuration information of the application program from the configuration file corresponding to the application program.

在本发明实施例中,通过Kubernetes中的controller(控制器)机制订阅监控配置信息的状态,一旦监控到应用程序的配置信息发生变动,从ConfigMap获取应用程序变动后的配置信息。其中,所述变动为更新或更改。在本发明的其他实施例中,也可采用其他方法来监控应用程序配置信息的变动。In the embodiment of the present invention, the status of the monitoring configuration information is subscribed through the controller mechanism in Kubernetes. Once the configuration information of the application is monitored to change, the changed configuration information of the application is obtained from the ConfigMap. Among them, the changes are updates or changes. In other embodiments of the present invention, other methods may also be used to monitor changes in application configuration information.

在本发明实施例中,通过对应用程序的对象的标注的监控来监控应用程序的配置信息是否发生变动。例如,在应用程序的对象的标注中设置有第一字段,该字段用于反映应用程序配置信息是否发生变动。所述标注的第一字段的一种描述方式为annotation(update-on-config-change:true),如果存在annotation(update-on-config-change:true),则意味着应用程序配置信息发生变动,反之,应用程序配置信息就没有发生变动。In the embodiment of the present invention, whether the configuration information of the application program changes is monitored by monitoring the annotations of the application program objects. For example, a first field is set in the annotation of the application object, and this field is used to reflect whether the application configuration information changes. One way of describing the first field of the annotation is annotation(update-on-config-change:true). If annotation(update-on-config-change:true) exists, it means that the application configuration information has changed. , on the contrary, the application configuration information will not change.

步骤102、确定所述应用程序的变动后配置信息与所述应用程序当前执行的配置信息不一致,触发所述应用程序重启以执行变动后配置信息。Step 102: Determine that the changed configuration information of the application program is inconsistent with the configuration information currently executed by the application program, and trigger a restart of the application program to execute the changed configuration information.

所述应用程序当前执行的配置信息是已知信息,它可以是从应用程序的对象中实时获取的,也可以是预先获取并存储的,也可以是本领域技术人员所能想到的其他方式获取的,在本发明实施例中不对其获取方式予以限定。The configuration information currently executed by the application program is known information. It can be obtained in real time from the object of the application program, or it can be obtained and stored in advance, or it can be obtained in other ways that those skilled in the art can think of. , the acquisition method is not limited in the embodiment of the present invention.

在本步骤中,应用程序重启后,将执行变动后配置信息。此时,变动后配置信息已经成为应用程序当前执行的配置信息,将该变动后配置信息作为应用程序当前执行的配置信息进行存储。例如,计算变动后的配置信息的哈希值,将这一变动后的配置信息的哈希值存储在应用程序的标注的第二字段。所述标注的第二字段的一种描述方式为annotation(version/config:hash),该第二字段用于保存应用程序当前执行的配置信息。由于应用程序当前执行的配置信息是变动后的配置信息,因此第二字段中将保存变动后配置信息。In this step, after the application is restarted, the changed configuration information will be executed. At this time, the changed configuration information has become the configuration information currently executed by the application program, and the changed configuration information is stored as the configuration information currently executed by the application program. For example, a hash value of the changed configuration information is calculated, and the hash value of the changed configuration information is stored in the second field of the annotation of the application program. One description method of the second field of the annotation is annotation (version/config:hash), and the second field is used to save the configuration information currently executed by the application program. Since the configuration information currently executed by the application is the changed configuration information, the changed configuration information will be stored in the second field.

本发明实施例提供的触发应用程序更改的方法通过对应用程序配置信息变动的实时监控,迅速发现变动后配置信息与应用程序当前执行的配置信息不同的问题,进而触发应用程序重启,实现应用程序的更改。The method for triggering application changes provided by the embodiment of the present invention quickly detects the problem that the changed configuration information is different from the configuration information currently executed by the application through real-time monitoring of changes in the application configuration information, thereby triggering the application to restart and realizing the application. changes.

基于上述任一实施例,图2为本发明另一实施例提供的触发应用程序更改的方法的流程图,如图2所示,本发明另一实施例提供的触发应用程序更改的方法包括:Based on any of the above embodiments, Figure 2 is a flow chart of a method for triggering application changes provided by another embodiment of the present invention. As shown in Figure 2, a method for triggering application changes provided by another embodiment of the present invention includes:

步骤201、监控到应用程序触发目标事件,获取所述应用程序当前执行的配置信息并存储。Step 201: Monitor the target event triggered by the application program, obtain and store the configuration information currently executed by the application program.

在本发明的实施例中,通过Kubernetes中的controller机制实现对应用程序中目标事件的监控。在本发明的其他实施例中,也可采用其他方法来监控应用程序中的目标事件。In the embodiment of the present invention, the monitoring of target events in the application is implemented through the controller mechanism in Kubernetes. In other embodiments of the present invention, other methods may also be used to monitor target events in the application program.

所述的目标事件一般是对应用程序产生影响的事件,例如,创建事件、读取事件、更新事件。The target events are generally events that have an impact on the application, such as create events, read events, and update events.

应用程序当前执行的配置信息可从应用程序对象中获取。Configuration information for the current execution of the application can be obtained from the application object.

在本发明实施例中,所获取的应用程序当前执行的配置信息存储在应用程序对象的标注中。例如,计算应用程序当前执行的配置信息的哈希值,将所得到的配置信息的哈希值存储在应用程序对象的标注的第二字段中(如annotation中的字段version/config:hash)。在本发明的其他实施例中,也可采用其他的存储方式。In this embodiment of the present invention, the obtained configuration information of the currently executed application is stored in the annotation of the application object. For example, calculate the hash value of the configuration information currently executed by the application, and store the obtained hash value of the configuration information in the second field of the annotation of the application object (such as the field version/config:hash in the annotation). In other embodiments of the present invention, other storage methods may also be used.

步骤202、监控到应用程序的配置信息发生变动,从所述应用程序所对应的配置文件中获取所述应用程序的变动后配置信息。Step 202: Monitor changes in the configuration information of the application program, and obtain the changed configuration information of the application program from the configuration file corresponding to the application program.

步骤203、确定所述应用程序的变动后配置信息与所述应用程序当前执行的配置信息不一致,触发所述应用程序重启以执行变动后配置信息。Step 203: Determine that the changed configuration information of the application program is inconsistent with the configuration information currently executed by the application program, and trigger a restart of the application program to execute the changed configuration information.

在本发明实施例中,所述应用程序当前执行的配置信息是通过步骤201获取的。In this embodiment of the present invention, the configuration information currently executed by the application program is obtained through step 201.

本发明实施例提供的触发应用程序更改的方法通过对应用程序配置信息变动的实时监控以及应用程序目标事件的监控,能迅速发现变动后配置信息与应用程序当前执行的配置信息不同的问题,进而触发应用程序重启,实现应用程序的更改。The method for triggering application changes provided by the embodiment of the present invention can quickly discover the problem that the changed configuration information is different from the configuration information currently executed by the application through real-time monitoring of changes in application configuration information and monitoring of application target events, and thus Trigger application restart to implement application changes.

基于上述任一实施例,图3为本发明又一实施例提供的触发应用程序更改的方法的流程图,如图3所示,本发明又一实施例提供的触发应用程序更改的方法包括:Based on any of the above embodiments, Figure 3 is a flow chart of a method for triggering application changes provided by yet another embodiment of the present invention. As shown in Figure 3, a method for triggering application changes provided by yet another embodiment of the present invention includes:

步骤301、为所要监控的应用程序设置标注。Step 301: Set annotations for the applications to be monitored.

在本发明实施例中,为需要做监控的应用程序设置一个标注。所述标注至少包括单一字段与第二字段,其中的第一字段用于描述应用程序的配置信息是否发生变动,第二字段用于保存应用程序当前执行的配置信息。In this embodiment of the present invention, a label is set for the application program that needs to be monitored. The annotation at least includes a single field and a second field, where the first field is used to describe whether the configuration information of the application program has changed, and the second field is used to save the configuration information currently executed by the application program.

步骤302、监控到应用程序触发目标事件,获取所述应用程序当前执行的配置信息并存储。Step 302: Monitor the target event triggered by the application program, obtain and store the configuration information currently executed by the application program.

步骤303、监控到应用程序的配置信息发生变动,从所述应用程序所对应的配置文件中获取所述应用程序的变动后配置信息。Step 303: Monitor changes in the configuration information of the application program, and obtain the changed configuration information of the application program from the configuration file corresponding to the application program.

步骤304、确定所述应用程序的变动后配置信息与所述应用程序当前执行的配置信息不一致,触发所述应用程序重启以执行变动后配置信息。Step 304: Determine that the changed configuration information of the application program is inconsistent with the configuration information currently executed by the application program, and trigger a restart of the application program to execute the changed configuration information.

本发明实施例提供的触发应用程序更改的方法通过标注的设置来实现对应用程序配置信息变动的监控以及应用程序配置信息的存储。The method for triggering application changes provided by the embodiment of the present invention realizes monitoring of changes in application configuration information and storage of application configuration information through marked settings.

基于上述任一实施例,在本发明再一实施例提供的触发应用程序更改的方法中,所述确定所述应用程序的变动后配置信息与所述应用程序当前执行的配置信息不一致进一步包括:Based on any of the above embodiments, in a method for triggering application changes provided by yet another embodiment of the present invention, determining that the changed configuration information of the application is inconsistent with the configuration information currently executed by the application further includes:

计算所述应用程序的变动后配置信息的哈希值;Calculate the hash value of the changed configuration information of the application;

计算所述应用程序当前执行的配置信息的哈希值;Calculate a hash value of the configuration information currently executed by the application;

确定所述应用程序的变动后配置信息的哈希值与所述应用程序当前执行的配置信息的哈希值不一致。It is determined that the hash value of the changed configuration information of the application program is inconsistent with the hash value of the configuration information currently executed by the application program.

本发明实施例提供的触发应用程序更改的方法为应用程序的变动后配置信息以及当前执行的配置信息计算哈希值,通过哈希值的比较来确定变动后配置信息与当前执行的配置信息是否一致,比较过程更为快捷,进而提高了整个方法的效率。The method for triggering application changes provided by the embodiment of the present invention calculates a hash value for the changed configuration information of the application program and the currently executed configuration information, and determines whether the changed configuration information and the currently executed configuration information are compared by comparing the hash values. Consistent, the comparison process is faster, thereby improving the efficiency of the entire method.

基于上述任一实施例,图4为本发明实施例提供的触发应用程序更改的装置的结构图,如图4所示,本发明实施例提供的触发应用程序更改的装置包括:Based on any of the above embodiments, Figure 4 is a structural diagram of a device for triggering application changes provided by an embodiment of the present invention. As shown in Figure 4, the device for triggering application changes provided by an embodiment of the present invention includes:

变动后配置信息获取模块401,用于监控到应用程序的配置信息发生变动,从所述应用程序所对应的配置文件中获取所述应用程序的变动后配置信息;The post-change configuration information acquisition module 401 is used to monitor changes in the configuration information of the application program and obtain the post-change configuration information of the application program from the configuration file corresponding to the application program;

应用程序重启触发模块402,用于确定所述应用程序的变动后配置信息与所述应用程序当前执行的配置信息不一致,触发所述应用程序重启以执行变动后配置信息。The application restart trigger module 402 is used to determine that the changed configuration information of the application program is inconsistent with the configuration information currently executed by the application program, and trigger the restart of the application program to execute the changed configuration information.

本发明实施例提供的触发应用程序更改的装置通过对应用程序配置信息变动的实时监控,迅速发现变动后配置信息与应用程序当前执行的配置信息不同的问题,进而触发应用程序重启,实现应用程序的更改。The device for triggering application changes provided by the embodiment of the present invention quickly detects the problem that the changed configuration information is different from the configuration information currently executed by the application through real-time monitoring of changes in the application configuration information, thereby triggering the application to restart and realizing the application. changes.

下面结合一个具体的实例对本发明实施例提供的触发应用程序更改的方法做进一步说明。The method for triggering application changes provided by the embodiment of the present invention will be further described below with reference to a specific example.

在该实例中,Deployment是Kubernetes中的一种资源,代表应用程序。In this instance, a Deployment is a resource in Kubernetes that represents an application.

相关步骤如下:The relevant steps are as follows:

首先,在Kubernetes中创建控制器监控的Deployment的创建事件或读取事件或更新事件,当Deployment创建时,控制器检查Deployment的Pod Template是否存在annotation(update-on-config-change:true),如果annotation不存在,控制器将忽略该Deployment。如果annotation存在,通过Deployment中ConfigMap的引用获取到ConfigMap,并对ConfigMap执行哈希运算(常用MD5或者SHA算法),将得到的哈希值存储在Deployment的Pod Template的annotation(version/config:hash值)中,并将Deployment的引用存储在控制器的监控列表中。当Deployment更新ConfigMap时,控制器会重新计算哈希值并更新存储到Deployment的annotation中。First, create a creation event or read event or update event of the Deployment monitored by the controller in Kubernetes. When the Deployment is created, the controller checks whether the Deployment's Pod Template exists annotation (update-on-config-change: true). If annotation does not exist, the controller will ignore the Deployment. If the annotation exists, obtain the ConfigMap through the reference of the ConfigMap in the Deployment, perform a hash operation (commonly used MD5 or SHA algorithm) on the ConfigMap, and store the obtained hash value in the annotation (version/config:hash value) of the Deployment's Pod Template ) and stores a reference to the Deployment in the controller's monitoring list. When the Deployment updates the ConfigMap, the controller will recalculate the hash value and update the annotation stored in the Deployment.

另外,控制器还监控了ConfigMap的更新事件,当ConfigMap发生更新时,通过Owner References跟踪哪些Deployment使用了该ConfigMap,重新计算ConfigMap的哈希值和原来的Deployment存储的哈希值比较,如果不相同,更新Deployment的Pod Template的annotation(version/config:hash值)的哈希值,重启应用程序加载新的配置信息。In addition, the controller also monitors the update event of ConfigMap. When ConfigMap is updated, it tracks which Deployments use the ConfigMap through Owner References, recalculates the hash value of ConfigMap and compares it with the hash value stored in the original Deployment, if it is not the same , update the hash value of the annotation (version/config:hash value) of the Deployment's Pod Template, and restart the application to load the new configuration information.

图5示例了一种电子设备的实体结构示意图,如图5所示,该电子设备可以包括:处理器(processor)510、通信接口(Communications Interface)520、存储器(memory)530和通信总线540,其中,处理器510,通信接口520,存储器530通过通信总线540完成相互间的通信。处理器510可以调用存储器530中的逻辑指令,以执行如下方法:监控到应用程序的配置信息发生变动,从所述应用程序所对应的配置文件中获取所述应用程序的变动后配置信息;确定所述应用程序的变动后配置信息与所述应用程序当前执行的配置信息不一致,触发所述应用程序重启以执行变动后配置信息。Figure 5 illustrates a schematic diagram of the physical structure of an electronic device. As shown in Figure 5, the electronic device may include: a processor (processor) 510, a communications interface (Communications Interface) 520, a memory (memory) 530 and a communication bus 540. Among them, the processor 510, the communication interface 520, and the memory 530 complete communication with each other through the communication bus 540. The processor 510 can call logical instructions in the memory 530 to perform the following method: monitor changes in the configuration information of the application program, obtain the changed configuration information of the application program from the configuration file corresponding to the application program; determine If the changed configuration information of the application program is inconsistent with the configuration information currently executed by the application program, the application program is triggered to restart to execute the changed configuration information.

需要说明的是,本实施例中的电子设备在具体实现时可以为服务器,也可以为PC机,还可以为其他设备,只要其结构中包括如图5所示的处理器510、通信接口520、存储器530和通信总线540,其中处理器510,通信接口520,存储器530通过通信总线540完成相互间的通信,且处理器510可以调用存储器530中的逻辑指令以执行上述方法即可。本实施例不对电子设备的具体实现形式进行限定。It should be noted that the electronic device in this embodiment can be a server, a PC, or other devices during specific implementation, as long as its structure includes the processor 510 and the communication interface 520 as shown in Figure 5 , memory 530 and communication bus 540, where the processor 510, the communication interface 520, and the memory 530 complete communication with each other through the communication bus 540, and the processor 510 can call the logical instructions in the memory 530 to execute the above method. This embodiment does not limit the specific implementation form of the electronic device.

此外,上述的存储器530中的逻辑指令可以通过软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。In addition, the above-mentioned logical instructions in the memory 530 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program code. .

进一步地,本发明实施例公开一种计算机程序产品,所述计算机程序产品包括存储在非暂态计算机可读存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,计算机能够执行上述各方法实施例所提供的方法,例如包括:监控到应用程序的配置信息发生变动,从所述应用程序所对应的配置文件中获取所述应用程序的变动后配置信息;确定所述应用程序的变动后配置信息与所述应用程序当前执行的配置信息不一致,触发所述应用程序重启以执行变动后配置信息。Further, an embodiment of the present invention discloses a computer program product. The computer program product includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, During execution, the computer can execute the methods provided by the above method embodiments, for example, including: monitoring changes in the configuration information of the application program, and obtaining the changed configuration information of the application program from the configuration file corresponding to the application program. ; Determine that the changed configuration information of the application program is inconsistent with the configuration information currently executed by the application program, and trigger a restart of the application program to execute the changed configuration information.

另一方面,本发明实施例还提供一种非暂态计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现以执行上述各实施例提供的方法,例如包括:监控到应用程序的配置信息发生变动,从所述应用程序所对应的配置文件中获取所述应用程序的变动后配置信息;确定所述应用程序的变动后配置信息与所述应用程序当前执行的配置信息不一致,触发所述应用程序重启以执行变动后配置信息。On the other hand, embodiments of the present invention also provide a non-transitory computer-readable storage medium on which a computer program is stored. The computer program is implemented when executed by a processor to perform the methods provided by the above embodiments, for example, including: Monitoring changes in the configuration information of the application program, obtaining the changed configuration information of the application program from the configuration file corresponding to the application program; determining the changed configuration information of the application program and the current execution of the application program The configuration information is inconsistent, triggering the application to restart to execute the changed configuration information.

以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。The device embodiments described above are only illustrative. The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they may be located in One location, or it can be distributed across multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Persons of ordinary skill in the art can understand and implement the method without any creative effort.

通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分所述的方法。Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the part of the above technical solution that essentially contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., including a number of instructions to cause a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in various embodiments or certain parts of the embodiments.

最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that it can still be used Modifications are made to the technical solutions described in the foregoing embodiments, or equivalent substitutions are made to some of the technical features; however, these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (6)

1. A method of triggering an application change, comprising:
setting labels for objects of the application program to be monitored; the label comprises a first field for describing whether the configuration information of the application program changes or not and a second field for storing the configuration information currently executed by the application program;
monitoring the triggering target event of the application program, acquiring the configuration information currently executed by the application program, calculating the hash value of the configuration information currently executed by the application program, and storing the hash value of the configuration information currently executed by the application program in the second field; the target event is a creation event or a reading event or an updating event of the application program;
monitoring that the configuration information of the application program changes, and acquiring the changed configuration information of the application program from a configuration file corresponding to the application program;
determining that the configuration information after the change of the application program is inconsistent with the configuration information currently executed by the application program, and triggering the application program to restart so as to execute the configuration information after the change;
the determining that the configuration information of the application program after the change is inconsistent with the configuration information currently executed by the application program comprises the following steps:
calculating a hash value of the changed configuration information of the application program;
determining that the hash value of the configuration information after the change of the application program is inconsistent with the hash value of the configuration information currently executed by the application program;
the method further comprises the steps of: and updating the hash value of the changed configuration information of the application program to the second field and storing the reference of the application program in a monitoring list.
2. The method of claim 1, wherein monitoring for changes in configuration information of an application comprises: the controller in Kubernetes is used to monitor the configuration information of the application program for changes.
3. The method of triggering an application modification according to claim 1, wherein the monitoring for an application trigger target event comprises: the controller in Kubernetes is employed to monitor the application for triggering a target event.
4. An apparatus for triggering an application change, comprising:
the setting module is used for setting labels for the objects of the application program to be monitored; the label comprises a first field for describing whether the configuration information of the application program changes or not and a second field for storing the configuration information currently executed by the application program;
the current execution configuration information acquisition module is used for monitoring the application program triggering target event, acquiring the configuration information currently executed by the application program, calculating the hash value of the configuration information currently executed by the application program, and storing the hash value of the configuration information currently executed by the application program in the second field; the target event is a creation event or a reading event or an updating event of the application program;
the post-change configuration information acquisition module is used for monitoring the change of the configuration information of the application program and acquiring the post-change configuration information of the application program from a configuration file corresponding to the application program;
an application restart triggering module, configured to determine that the configuration information after the change of the application is inconsistent with the configuration information currently executed by the application, and trigger the application to restart to execute the configuration information after the change;
the determining that the configuration information of the application program after the change is inconsistent with the configuration information currently executed by the application program comprises the following steps:
calculating a hash value of the changed configuration information of the application program;
determining that the hash value of the configuration information after the change of the application program is inconsistent with the hash value of the configuration information currently executed by the application program;
the device is also for: and updating the hash value of the changed configuration information of the application program to the second field and storing the reference of the application program in a monitoring list.
5. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor performs the steps of the method of triggering an application modification as claimed in any one of claims 1 to 3 when the program is executed.
6. A non-transitory computer readable storage medium having stored thereon a computer program, which when executed by a processor performs the steps of the method of triggering an application modification as claimed in any of claims 1 to 3.
CN202010153088.6A 2020-03-06 2020-03-06 Method, device, electronic equipment and storage medium for triggering application program change Active CN111381932B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010153088.6A CN111381932B (en) 2020-03-06 2020-03-06 Method, device, electronic equipment and storage medium for triggering application program change

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010153088.6A CN111381932B (en) 2020-03-06 2020-03-06 Method, device, electronic equipment and storage medium for triggering application program change

Publications (2)

Publication Number Publication Date
CN111381932A CN111381932A (en) 2020-07-07
CN111381932B true CN111381932B (en) 2024-03-22

Family

ID=71217182

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010153088.6A Active CN111381932B (en) 2020-03-06 2020-03-06 Method, device, electronic equipment and storage medium for triggering application program change

Country Status (1)

Country Link
CN (1) CN111381932B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115309457B (en) * 2022-08-10 2023-10-27 中电金信软件有限公司 Restarting method and device of application instance, electronic equipment and readable storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6757900B1 (en) * 2000-05-18 2004-06-29 Microsoft Corporation State management of server-side control objects
CN108228282A (en) * 2018-04-04 2018-06-29 北京三快在线科技有限公司 For the method and device of Website page loading
CN108600029A (en) * 2018-05-09 2018-09-28 深圳壹账通智能科技有限公司 A kind of configuration file update method, device, terminal device and storage medium
CN110392042A (en) * 2019-06-19 2019-10-29 深圳壹账通智能科技有限公司 System environments resource allocation information acquisition methods, device and block chain node
CN110413346A (en) * 2019-07-30 2019-11-05 中国工商银行股份有限公司 A kind of parameter updating method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2546239A (en) * 2015-11-23 2017-07-19 Acadiant Ltd A Method and system for providing and executing web applications

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6757900B1 (en) * 2000-05-18 2004-06-29 Microsoft Corporation State management of server-side control objects
CN108228282A (en) * 2018-04-04 2018-06-29 北京三快在线科技有限公司 For the method and device of Website page loading
CN108600029A (en) * 2018-05-09 2018-09-28 深圳壹账通智能科技有限公司 A kind of configuration file update method, device, terminal device and storage medium
CN110392042A (en) * 2019-06-19 2019-10-29 深圳壹账通智能科技有限公司 System environments resource allocation information acquisition methods, device and block chain node
CN110413346A (en) * 2019-07-30 2019-11-05 中国工商银行股份有限公司 A kind of parameter updating method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
"网络动态防御策略及其有效性评估研究";刘江;《中国博士学位论文全文数据库 信息科技辑》;I139-14页 *
Jennifer Rexford等."PISCES:A Programmable,Protocol-Independent Software Switch".《SIGCOMM'16:Proceedings of the 2016 ACM SIGCOMM Conference》.2016,第525-538页. *

Also Published As

Publication number Publication date
CN111381932A (en) 2020-07-07

Similar Documents

Publication Publication Date Title
CN108600029B (en) A configuration file updating method, device, terminal device and storage medium
CN111897558A (en) Container cluster management system Kubernetes upgrade method and device
CN112702195A (en) Gateway configuration method, electronic device and computer readable storage medium
CN116319758A (en) Data migration method, device, electronic equipment and readable storage medium
CN111381932B (en) Method, device, electronic equipment and storage medium for triggering application program change
CN114201458A (en) Information updating method, micro-service system and computer readable storage medium
CN111858234A (en) A task execution method, apparatus, device and medium
CN113595762B (en) Network card configuration storage method and device
CN110784353A (en) Network element equipment configuration data migration method and device
CN112948020B (en) Configuration file processing method and device
CN109101253B (en) Management method and device for host in cloud computing system
CN114564211A (en) Cluster deployment method, cluster deployment device, equipment and medium
CN114721876A (en) Data backup method, device and medium
CN113656378A (en) A server management method, device and medium
CN108958885A (en) A kind of management method and device of configuration information
CN116893834B (en) Load update method, device, system, electronic equipment and readable storage medium
CN110750503A (en) File deletion speed control method, device, equipment and readable storage medium
CN110399028A (en) A method, device and medium for preventing power surges during batch operation of power supplies
CN117240711B (en) Automatic updating method, device and equipment for cluster management tool configuration file
CN119476534B (en) Artificial intelligence training platform starting method, computer equipment and storage medium
CN118885449B (en) Checkpoint file storage method, device, electronic device and storage medium
CN113553097B (en) Model version management method and device
CN117170701A (en) Upgrading method, device and medium for baseboard management controller
CN120144048A (en) Data management method, device, equipment and storage medium
CN113849291A (en) Task processing method, device, device, medium and product based on container cluster

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