Gateway, gateway hot upgrade method and system
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-17
- Publication Date
- 2026-08-11
AI Technical Summary
现有的网关热升级方案中,子进程接收到父进程传输的FD(File Descriptor,文件描述符)之后,向父进程发送消息,以使父进程执行退出,而父进程机械性的等待一段时间退出,可能存在请求在等待时间内未收到回复就退出,不能保证进程的优雅退出
[0012] In this embodiment, upon receiving an exit signal, the connection between the parent process of the service request before the hot upgrade and the child process after the hot upgrade is disconnected. The service request is used to establish a connection between the child process after the hot upgrade and the parent process before the hot upgrade. The child process, after establishing the connection, receives port information and file descriptor information transferred by the parent process; exits the parent process; and processes the service request using the port information and file descriptor information. This application disconnects the connection between the parent process before the hot upgrade and the child process after the hot upgrade upon receiving an exit signal. By performing the disconnection operation based on the exit signal, the exit process of the parent process is controlled, thereby reducing the likelihood of the parent process exiting before a response is received within the waiting time, and further ensuring a graceful exit of the parent process.
Smart Images

Figure CN116599796B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cloud computing, and in particular to a gateway, a gateway hot upgrade method and system. Background Technology
[0002] This section is intended to provide background or context for the embodiments of the invention set forth in the claims. The description herein is not an admission that it is prior art simply because it is included in this section.
[0003] As a critical infrastructure carrying inbound and outbound traffic on a machine, the gateway needs to have hot upgrade capabilities during application redeployment or upgrades. This ensures that inbound and outbound traffic is not blocked, thus preventing interruption of service requests and responses on the machine and guaranteeing service availability. In existing gateway hot upgrade solutions, after the child process receives the FD (File Descriptor) transmitted by the parent process, it sends a message to the parent process to cause the parent process to exit. However, the parent process mechanically waits for a period of time before exiting. This can lead to situations where requests exit without receiving a response within the waiting period, failing to guarantee a graceful exit of the process. Summary of the Invention
[0004] This application provides a gateway, a gateway hot upgrade method and system, which can at least optimize the parent process exit process and enable the parent process to exit gracefully.
[0005] According to one aspect of this application, a gateway hot upgrade method is also provided, comprising: upon receiving an exit signal, disconnecting the connection between the parent process of the service request before the hot upgrade and the child process after the hot upgrade; wherein the service request is used to establish a connection between the child process after the hot upgrade and the parent process before the hot upgrade; the child process is used to receive port information and file descriptor information transferred by the parent process after establishing the connection; exiting the parent process; and processing the service request using the child process according to the port information and the file descriptor information.
[0006] According to another aspect of this application, a gateway hot-upgrade system is also provided, including a control module and a processing module: the control module is configured to disconnect the connection between the parent process of the service request before hot-upgrade and the child process after hot-upgrade when receiving an exit signal; wherein, the service request is used to establish a connection between the child process after hot-upgrade and the parent process before hot-upgrade; the child process is configured to receive port information and file descriptor information transferred by the parent process after establishing the connection; the processing module is configured to exit the parent process and process the service request using the child process according to the port information and the file descriptor information.
[0007] According to another aspect of this application, a gateway is also provided that performs gateway hot upgrades according to the above-described method steps.
[0008] According to another aspect of this application, an electronic device is also provided, comprising: a processor; and a memory storing a program, wherein the program includes instructions that, when executed by the processor, cause the processor to perform the method described above.
[0009] According to another aspect of this application, a non-transitory computer-readable storage medium storing computer instructions is also provided, wherein the computer instructions are used to cause the computer to perform the method steps according to the above description.
[0010] According to another aspect of this application, a computer program product is also provided, the computer program product comprising a computer program that, when executed by a processor, implements the above-described method steps.
[0011] Beneficial effects of the embodiments of the present invention:
[0012] In this embodiment, upon receiving an exit signal, the connection between the parent process of the service request before the hot upgrade and the child process after the hot upgrade is disconnected. The service request is used to establish a connection between the child process after the hot upgrade and the parent process before the hot upgrade. The child process, after establishing the connection, receives port information and file descriptor information transferred by the parent process; exits the parent process; and processes the service request using the port information and file descriptor information. This application disconnects the connection between the parent process before the hot upgrade and the child process after the hot upgrade upon receiving an exit signal. By performing the disconnection operation based on the exit signal, the exit process of the parent process is controlled, thereby reducing the likelihood of the parent process exiting before a response is received within the waiting time, and further ensuring a graceful exit of the parent process.
[0013] Details of one or more embodiments of the present invention are set forth in the following drawings and description, so that other features, objects and advantages of the invention will be more readily understood. Attached Figure Description
[0014] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other embodiments can be obtained based on these drawings without creative effort.
[0015] Figure 1This is a flowchart of the gateway hot upgrade method according to an embodiment of the present invention;
[0016] Figure 2 This is a schematic diagram of a conventional gateway hot upgrade method according to an embodiment of the present invention;
[0017] Figure 3 This is a schematic diagram of a gateway hot upgrade method according to an embodiment of this application;
[0018] Figure 4 This is a structural block diagram of an exemplary electronic device that can be used to implement embodiments of the present invention. Detailed Implementation
[0019] Embodiments of the present invention will now be described in more detail with reference to the accompanying drawings. While some embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the invention. It should be understood that the accompanying drawings and embodiments are for illustrative purposes only and are not intended to limit the scope of protection of the invention.
[0020] Currently, in existing gateway hot upgrade solutions, see [link to relevant documentation]. Figure 2 The diagram illustrates an existing gateway hot upgrade method. When the parent and child processes start, they both create a socket and bind it to a specific UDS (Unix Domain Socket) file using the `bind` function (a function that binds a socket to a local address (IP address and port number)). For the first deployment of the application, since it has no parent process, the UDS file can be created. For subsequent hot upgrade child processes, since they have a parent process, they can communicate with the parent process by directly opening its UDS file. The following steps are based on the assumption that the child process has a parent process during the hot upgrade.
[0021] 1. Before the child process proceeds to the bind process, it needs to send a shutdownParent message (used to close the parent process) to the parent process. After receiving the message, the parent process stops listening and closes the socket. This allows new connections to fail quickly and prevents them from entering the accept queue.
[0022] 2. After receiving the response from step 1, the child process sends a passListenSocket message (used to pass instructions for the listening socket). The message will carry the FD type to be transmitted. For example, if the gateway currently only opens inbound and outbound ports, the inbound and outbound ports bound by the parent process, as well as the FD, can be transmitted to the child process. If new ports are opened in the future, the transmission can continue.
[0023] 3. When TLS (Transport Layer Security) encryption is enabled, the gateway will be in a certain state.
[0024] 4. After the child process receives the file descriptor (FD) from the parent process, it can accept new connections. The child process sends a `drainListenerAndkillParent` message (a command to notify the parent process to exit), allowing the parent process to exit gracefully. At this point, the remaining task for the parent process is to process the established connections. A certain amount of time is reserved for this process. After processing, the FD is cleaned up to prevent leakage, and then a graceful exit is performed.
[0025] In the above scheme, the parent process simply waits mechanically for a period of time before exiting. There is a possibility that the request will not receive a response within the waiting time and will exit, which cannot guarantee the graceful exit of the process.
[0026] Gateways themselves need to possess high availability characteristics to ensure the reliability of network communication for the components they proxies, serving as an infrastructure. Therefore, based on this background, this application proposes a gateway, a gateway hot-upgrade method, and a system. This method can optimize the parent process's exit process, enabling the parent process to exit gracefully.
[0027] The following is an explanation of the terms involved.
[0028] Hot upgrade: refers to the act of upgrading application services without interruption.
[0029] Gateway software: Software that performs network request translation and proxying. It can run on ordinary computers or servers, enabling communication between different networks or protocols. Gateway software typically includes routers, firewalls, proxy servers, etc., and can implement different gateway functions.
[0030] Graceful exit: The normal termination or shutdown of a program, system, or network connection. This exit method can prevent abnormalities or errors from occurring when the program or system ends, avoid data loss or corruption, and thus ensure data integrity and security.
[0031] This embodiment provides a gateway hot upgrade method, which can be applied to the server side. The server can provide gateway services to the client based on the client's service request. The gateway service can be implemented through gateway software. Figure 1 This is a flowchart of a gateway hot upgrade method according to an embodiment of this application. The following describes... Figure 1 The methods and steps involved are explained.
[0032] Step S102: Upon receiving an exit signal, disconnect the connection between the parent process before the hot upgrade and the child process after the hot upgrade of the service request; wherein, the service request is used to establish a connection between the child process after the hot upgrade and the parent process before the hot upgrade; the child process is used to receive the port information and file descriptor information transferred by the parent process after the connection is established.
[0033] In this step, the service request can be sent by the client to the gateway, which then requests services from the server it resides in. It should be noted that the gateway can be a hardware device or implemented through gateway software. This service request can be used to establish a connection between the child process after the hot upgrade and its parent process before the hot upgrade. After establishing the connection, the child process receives the port information and file descriptor information transferred by the parent process.
[0034] The port information is used to determine the port from which the child process is transferred from the parent process. This port can be used to receive data packets, filter and perform security checks on data packets, perform network address translation, and send data packets. The specific port used can be determined according to actual needs, and this embodiment of the invention does not impose specific limitations on this. In computer network programming, a socket is a communication mechanism that allows different processes to communicate over a network. Sockets typically use file descriptors (FDs) for operation. An FD is an integer, a unique identifier assigned by the operating system kernel to each open file or device. In socket programming, a socket FD refers to the file descriptor of a socket connection; it is an integer used to identify a socket connection. Socket FDs can be used to send and receive data, as well as perform other socket operations, such as setting socket options and closing socket connections. In socket programming, socket FDs are usually created using socket functions.
[0035] In this step, a process can be an instance of a running program. A process is the basic unit of execution in a computer system, containing information such as program code, data, and execution status. Processes typically use the Socket mechanism for communication; each process can create one or more Socket connections for communication with other processes. Communication between processes can be synchronous or asynchronous, sending and receiving data via Sockets or interacting through other communication mechanisms. In this step, there is a hierarchical relationship between the parent and child processes. A child process can be a copy of the parent process, sharing some resources, such as port information and file descriptor information, but they can also have some independent resources. The process that existed before the gateway hot upgrade is designated as the parent process, and the processes that share port information and file descriptor information with this parent process after the gateway hot upgrade are designated as child processes.
[0036] In this step, an exit signal is used to determine the time to initiate the asynchronous processing task. The exit signal can be sent in the form of a message or a command. A message can be information transmitted during communication, such as text, images, audio, or video. Commands can be used to control, adjust, or configure parameters of a device or system to achieve a specific purpose. The form of the exit signal can be determined by the sending end according to actual needs; this embodiment of the invention does not impose specific limitations on this.
[0037] In this step, upon receiving an exit signal, the operation of disconnecting the connection between the parent process and the child process is initiated through the exit signal, thereby controlling the disconnection operation and reducing the possibility of the parent process exiting before receiving a response within the waiting time.
[0038] Step S104: Exit the parent process and use the child process to process the service request based on the port information and the file descriptor information.
[0039] In this step, exiting the parent process means terminating the currently running parent process and releasing the system resources it occupies. The child process then processes the service request based on the port information and file descriptor information. This child process can be used to perform some or all of the work of the exiting parent process.
[0040] It should be noted here that hot upgrades via the gateway can transfer all or part of the work handled by the parent process to the child process.
[0041] Additionally, it should be noted that if a child process does not have a corresponding parent process, it means that the process is being deployed for the first time. In this case, a UDS file for the process can be created, and the port information and file descriptor information of the process can be obtained through the newly created UDS file.
[0042] In this embodiment, upon receiving an exit signal, the connection between the parent process of the service request before the hot upgrade and the child process after the hot upgrade is disconnected. The service request is used to establish a connection between the child process after the hot upgrade and the parent process before the hot upgrade. The child process, after establishing the connection, receives port information and file descriptor information transferred by the parent process; exits the parent process; and processes the service request using the port information and file descriptor information. This application disconnects the connection between the parent process before the hot upgrade and the child process after the hot upgrade upon receiving an exit signal. By performing the disconnection operation based on the exit signal, the exit process of the parent process is controlled, thereby reducing the likelihood of the parent process exiting before a response is received within the waiting time, and further ensuring a graceful exit of the parent process.
[0043] In one possible implementation, the scheme further includes an asynchronous processing task that generates the service request; the asynchronous processing task is used to disconnect the connection between the parent process and the child process; when an exit signal is received, disconnecting the connection between the parent process before the hot upgrade of the service request and the child process after the hot upgrade can be performed by the following steps: using an asynchronous processing component to execute the asynchronous processing task.
[0044] In this possible implementation, after receiving a service request, the gateway generates a corresponding asynchronous processing task for each service request. For example, this asynchronous processing task could be a Tokio task (an asynchronous I / O (Input / Output) runtime library that provides an efficient way to write asynchronous, concurrent, and scalable network applications), used to disconnect the connection between the parent process and the child process.
[0045] It should be noted that asynchronous task processing can be referenced from coroutines, which can be paused and resumed during execution, thereby realizing task switching and scheduling.
[0046] In this step, a corresponding asynchronous processing task is generated for each service request. After the task is executed, the connection between the parent process and the child process can be disconnected. Thus, by controlling the execution of the asynchronous processing task, the connection status between the parent process and the child process can be controlled, that is, the timing of releasing the connection can be controlled.
[0047] Asynchronous processing components can be used to execute asynchronous processing tasks, thereby disconnecting the parent process from the child process. These components can be implemented based on the `select` macro. `select` is a system call used to wait for data to arrive on multiple file descriptors. The `select` macro is a function that encapsulates the `select` system call, used to wait for data to arrive on a set of file descriptors.
[0048] In this step, the asynchronous processing task is executed only when an exit signal is received. This allows the operation of disconnecting the connection between the parent process and the child process to be initiated through the exit signal, thereby controlling the disconnection operation and reducing the possibility of the parent process exiting before receiving a response within the waiting time.
[0049] In one possible implementation, the exit signal is issued by the client or the server; the asynchronous processing component includes a first processing component and a second processing component; the asynchronous processing task can be executed using the asynchronous processing component in the following steps: if the first exit signal issued by the client is received first, the connection between the parent process and the child process is disconnected using the first processing component; if the second exit signal issued by the server is received first, the connection between the parent process and the child process is disconnected using the second processing component.
[0050] In this possible implementation, the client and server can be processes running on different computers that communicate over a network. The client sends a request message to the server, the server receives and processes the request message, and finally returns a response message to the client.
[0051] During gateway hot upgrades, the exit of the parent process can be controlled by either the client or the server. For example, if the client needs to pause the hot upgrade and control the parent process to exit prematurely, it will send an exit signal, which will be used as the first exit signal. During a normal hot upgrade, the server can control the timing of the parent process's exit by sending an exit signal, which will be used as the second exit signal. For example, in one possible implementation, this second exit signal can be sent after the child process has completed processing the connection request or after the connection request times out, thereby ensuring a graceful exit of the parent process.
[0052] If the first exit signal from the client is received before the second exit signal from the server is received, the first processing component executes an asynchronous processing task to disconnect the connection between the parent process and the child process. If the second exit signal from the server is received before the first exit signal from the client is received, the second processing component executes an asynchronous processing task to disconnect the connection between the parent process and the child process.
[0053] In this step, whichever of the first and second processing components is responded to first, the responded component will process the corresponding task according to the received exit signal, thereby controlling the timing of the disconnection between the parent process and the child process, and thus ensuring the graceful exit of the parent process.
[0054] It should be noted that the first processing component or the second processing component can be an independent module or part of the software system, which can be developed, tested, deployed and maintained independently; it can have clearly defined interfaces and functions, and can be called and used by other components or systems.
[0055] Considering that in the process management module, when a parent process exits, it may be identified as an abnormal exit, which could easily lead to the parent process being restarted, resulting in wasted resources. In one possible implementation, exiting the parent process can be performed according to the following steps: identifying the parent process based on a first identifier, and identifying the child process based on a second identifier; wherein the parent process is pre-marked in the process management module using the first identifier, and the child process is pre-marked in the process management module using the second identifier; controlling the parent process to be in an exited state, and controlling the child process to be in a running state.
[0056] In this possible implementation, the process management module can be used to manage the processes involved in the gateway. The specific process management method adopted by the process management module can be selected according to actual needs, and this embodiment of the invention does not impose specific limitations on it.
[0057] The first and second identifiers can be selected according to actual needs, and may include special characters, numbers, strings, etc. The parent process is pre-marked using the first identifier, and the child process is marked using the second identifier, thus distinguishing between the parent and child processes. The parent process is then identified based on the first identifier, and the child process is identified based on the second identifier. This allows control over whether the parent process is in an exited state or whether the child process is in a running state.
[0058] For example, in one possible implementation, the process management module is implemented using Systemd (a dependency-based process management method). Systemd can automatically start and stop system services and establish dependencies between services to ensure they start and stop in the correct order. If the gateway process is managed by Systemd, and Systemd has the function of adding managed processes to the daemon list (for example, this application can achieve this by adding rustyncproxy.service to / usr / lib / systemd / system / ), then Systemd can quickly restart the gateway process in time when it exits abnormally, ensuring the high availability of the gateway process. However, this mechanism also brings considerable trouble to the hot upgrade process of this application. Consider the following scenario: the gateway parent process is daemonized by Systemd. When the gateway child process connects to the parent process's UDS address, the parent process gracefully exits after handing over the file descriptor. At this time, Systemd detects the exit of the parent process and restarts it. Such a restart may affect the hot upgrade process.
[0059] To prevent the parent process from being restarted after it exits, when using Systemd's process management module, you can configure the service template name of the process to be managed as follows when adding the process to Systemd's daemon list:
[0060] rustyncproxy@.service is simply adding an "@" character to the end of the service name. Then, the parent process is named rustyncproxy@0.service, and the child process is named rustyncproxy@1.service. This way, the parent and child processes can be distinguished by the different parameters after "@" during hot upgrades.
[0061] To ensure that Systemd can quickly restart the gateway process in the event of an unexpected crash, in one possible implementation, after exiting the parent process, the following steps can also be performed:
[0062] Receive the return value after the parent process exits; the return value includes a first return value and a second return value; if the return value is the first return value, control the parent process to remain in the exit state; if the return value is the second return value, restart the parent process.
[0063] In this possible implementation, the parent process sends a return value after exiting. The return value includes a first return value and a second return value. The first return value can be returned if the parent process exits normally, for example, the first return value can be 0. The second return value can be returned if the parent process exits abnormally, for example, the second return value can be an exception message parameter, such as a termination signal (SIGTERM).
[0064] In this step, by distinguishing the return values, a first return value and a second return value are obtained. This ensures that if the parent process exits normally, it remains in the exit state, preventing it from being repeatedly restarted during hot upgrades. If the parent process exits abnormally, it is restarted based on the second return value, mitigating the problem of parent process exiting due to unexpected circumstances.
[0065] The port information may include various types of port information. In one possible implementation, the port information includes outbound port information and inbound port information; the service request is processed by the subprocess based on the port information and the file descriptor information, which can be performed according to the following steps:
[0066] The subprocess generates an outbound port based on the outbound port information and an inbound port based on the inbound port information; the subprocess generates a socket file based on the file descriptor information; and the service request is processed using the socket file, the outbound port, and the inbound port.
[0067] In this possible implementation, an inbound port refers to the port on the gateway device used to receive data packets from an external network. An outbound port refers to the port on the gateway device used to send data packets to an external network. Both types of ports can also be used for operations such as forwarding, routing, filtering, security checks, and address translation. They are important components of the gateway device and play a crucial role in protecting the security of the internal network and enabling network communication.
[0068] After the parent process transfers the outbound port information, inbound port information, and file descriptor information to the child process, the child process can generate its own outbound port, inbound port, and socket file based on the received information, thereby realizing some or all of the functions that the parent process can achieve.
[0069] In this step, the port information may include various types of port information, which are set according to actual needs. This embodiment of the invention does not impose specific limitations on this.
[0070] After the parent process exits, the child process can act as the new parent process during subsequent gateway hot upgrades, transferring port and file descriptor information to the new child process. Therefore, in one possible implementation, processing the service request using the child process based on the port and file descriptor information can be performed according to the following steps:
[0071] Receive a target service request from a target process; establish a connection between the child process and the target process; transfer the port information and the file descriptor information to the target process so that the target process can process the service request based on the port information and the file descriptor information.
[0072] In this possible implementation, when the child process acts as the parent process in a subsequent gateway hot upgrade process, the target process can act as a new child process. The service request of the target process can be used as a target service request. The target service request of the target process is received, and a connection is established between the child process and the target process. The port information and the file descriptor information are transferred to the target process so that the target process can process the service request according to the port information and the file descriptor information, thereby enabling the gateway to continuously perform hot upgrades.
[0073] The implementation of this method will be described below with a specific example.
[0074] See Figure 3 The diagram illustrates the gateway hot upgrade method. This application employs a dual-process coexistence approach for a period to ensure the transmission of socket file descriptors (FDs) between the new process (child process) and the old process (parent process), thus preventing network requests from being interrupted during the hot upgrade. At the start of the hot upgrade, the new gateway process attempts to connect to a specific UDS address. If the old process exists, it connects to the socket file previously created by the old process, transferring the inbound and outbound socket FDs created by the old process to the new process. If the old process does not exist, the connect fails, indicating either the first deployment of the gateway service or a Unix domain socket communication error. Retry and timeout policies are required to ensure the gateway service continues to operate.
[0075] When the new process receives the inbound and outbound socket file descriptors (FDs) transferred from the old process, it creates new inbound and outbound socket FDs based on these FDs and completes the bind operation. This allows new network requests passing through the gateway to be transferred to the new process for service. The old process does not immediately terminate; it waits for responses to previously established requests (or times out) before it can terminate. The new process can then act as a parent process in subsequent hot upgrades, connecting with new child processes and performing graceful exits, thus repeating the above process steps.
[0076] In the above steps, the old process must first ensure that it transfers the file descriptor (FD) to the new process when it receives a connect request from the new process. Then, it needs to immediately stop connecting its own inbound and outbound sockets to ensure that no new client connections are made. This can be achieved by using the select macro to handle the exit signal drain and the asynchronous connect task.
[0077] Secondly, the old process needs to wait for previously connected requests to complete. This is achieved by the gateway service assigning a tokio processing task (similar to a coroutine) to each request. Each task is assigned two asynchronous select macros. The first select macro handles early client exits, and the second select macro handles the exit signal (drain). The task that responds to the first asynchronous select macro will execute its corresponding task: the select macro for the exit signal (drain) is issued when the old process wants to gracefully exit. The corresponding processing task is to wait for the request to receive a reply or timeout response before releasing the connect. This ensures that requests that have already established a connection with the old process need to wait for a reply or timeout response.
[0078] This invention provides a gateway hot upgrade method. This method ensures that service requests that have already established connections with the old process need to wait for a response or timeout, and also ensures that new requests are processed by the new process. This ensures that business requests or responses are not interrupted during gateway upgrades, thus guaranteeing the high availability and high stability of the gateway.
[0079] This invention also provides a gateway hot-upgrade system, including a control module and a processing module: the control module is used to disconnect the connection between the parent process of the service request before hot-upgrade and the child process after hot-upgrade when an exit signal is received; wherein, the service request is used to establish a connection between the child process after hot-upgrade and the parent process before hot-upgrade; the child process is used to receive port information and file descriptor information transferred by the parent process after the connection is established; the processing module is used to exit the parent process and use the child process to process the service request according to the port information and the file descriptor information.
[0080] In this embodiment, upon receiving an exit signal, the connection between the parent process before the hot upgrade and the child process after the hot upgrade is disconnected. Based on the exit signal, the disconnection operation between the parent process and the child process is performed, thereby controlling the exit process of the parent process. This can reduce situations where the parent process exits before the service request receives a response within the waiting time, further ensuring the graceful exit of the parent process.
[0081] In one possible implementation, a generation module is further included, which generates an asynchronous processing task for the service request; the asynchronous processing task is used to disconnect the connection between the parent process and the child process; the control module is specifically used to execute the asynchronous processing task using an asynchronous processing component.
[0082] In one possible implementation, the exit signal is issued by the client or the server; the asynchronous processing component includes a first processing component and a second processing component; the control module is specifically configured to: if the first exit signal issued by the client is received first, then disconnect the connection between the parent process and the child process using the first processing component; if the second exit signal issued by the server is received first, then disconnect the connection between the parent process and the child process using the second processing component.
[0083] In one possible implementation, the second exit signal is issued after the subprocess has finished processing the connection request or after the connection request has timed out.
[0084] In one possible implementation, the processing module is configured to: identify the parent process according to a first identifier, and identify the child process according to a second identifier; wherein the parent process is pre-marked in the process management module by the first identifier, and the child process is pre-marked in the process management module by the second identifier; control the parent process to be in an exit state, and control the child process to be in a running state.
[0085] In one possible implementation, the processing module is further configured to: receive a return value after the parent process exits; the return value includes a first return value and a second return value; if the return value is the first return value, then control the parent process to remain in the exit state; if the return value is the second return value, then restart the parent process.
[0086] In one possible implementation, the port information includes outbound port information and inbound port information; the processing module is configured to: generate an outbound port based on the outbound port information using the subprocess, and generate an inbound port based on the inbound port information; generate a Socket file based on the file descriptor information using the subprocess; and process the service request using the Socket file, the outbound port, and the inbound port.
[0087] In one possible implementation, the processing module is further configured to: receive a target service request from a target process; establish a connection between the child process and the target process; and transfer the port information and the file descriptor information to the target process so that the target process can process the service request based on the port information and the file descriptor information.
[0088] This invention also provides an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor. The memory stores a computer program executable by the at least one processor, which, when executed by the at least one processor, causes the electronic device to perform a method according to an embodiment of the invention.
[0089] This invention also provides a gateway, wherein the gateway performs a hot upgrade according to the above-described method steps.
[0090] This invention also provides a non-transitory computer-readable storage medium storing a computer program, wherein the computer program, when executed by a computer's processor, is used to cause the computer to perform a method according to an embodiment of the invention.
[0091] This invention also provides a computer program product, including a computer program, wherein the computer program, when executed by a computer's processor, is used to cause the computer to perform a method according to an embodiment of the invention.
[0092] refer to Figure 4The present invention will now be described in the form of a structural block diagram of an electronic device 400 that can serve as a server or user of the present invention, which is an example of a hardware device that can be applied to various aspects of the present invention. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0093] like Figure 4 As shown, the electronic device 400 includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 402 or a computer program loaded from a storage unit 408 into a random access memory (RAM) 403. The RAM 403 may also store various programs and data required for the operation of the device 400. The computing unit 401, ROM 402, and RAM 403 are interconnected via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0094] Multiple components in electronic device 400 are connected to I / O interface 405, including: input unit 406, output unit 407, storage unit 408, and communication unit 409. Input unit 406 can be any type of device capable of inputting information to electronic device 400. Input unit 406 can receive input digital or character information and generate key signal inputs related to user settings and / or function control of electronic device. Output unit 407 can be any type of device capable of presenting information and may include, but is not limited to, a display, speaker, video / audio output terminal, vibrator, and / or printer. Storage unit 408 may include, but is not limited to, disks and optical discs. Communication unit 409 allows electronic device 400 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks, and may include, but is not limited to, modems, network cards, infrared communication devices, wireless communication transceivers, and / or chipsets, such as Bluetooth devices, WiFi devices, WiMax devices, cellular communication devices, and / or the like.
[0095] The computing unit 401 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 401 performs the various methods and processes described above. For example, in some embodiments, the aforementioned methods can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 408. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 400 via ROM 402 and / or communication unit 409. In some embodiments, the computing unit 401 can be configured to perform the aforementioned methods by any other suitable means (e.g., by means of firmware).
[0096] Program code for implementing the methods of embodiments of the present invention may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on the machine, partially on the machine, as a standalone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0097] In the context of embodiments of the present invention, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0098] It should be noted that the term "comprising" and its variations used in the embodiments of the present invention are open-ended, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The modifications of "one" and "multiple" mentioned in the embodiments of the present invention are illustrative and not restrictive. Those skilled in the art should understand that, unless explicitly indicated otherwise in the context, they should be understood as "one or more".
[0099] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0100] The steps described in the method embodiments provided by this invention can be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of protection of this invention is not limited in this respect.
[0101] The term "embodiment" in this specification refers to a specific feature, structure, or characteristic described in connection with an embodiment that may be included in at least one embodiment of the invention. The appearance of this phrase in various places in the specification does not necessarily imply the same embodiment, nor does it imply independence or alternativeity from other embodiments. The various embodiments in this specification are described in a related manner, with reference to each other for similar or identical parts. In particular, for apparatus, device, and system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, and relevant details are referred to in the description of the method embodiments.
[0102] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of patent protection. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the appended claims.
Claims
1. A gateway hot upgrade method, comprising: Upon receiving an exit signal, the connection between the parent process before the hot upgrade and the child process after the hot upgrade is disconnected; wherein, the service request is used to establish a connection between the child process after the hot upgrade and the parent process before the hot upgrade; the child process is used to receive the port information and file descriptor information transferred by the parent process after the connection is established; Exit the parent process, and use the child process to process subsequent service requests based on the port information and the file descriptor information; The method further includes: An asynchronous processing task is generated to handle the service request; the asynchronous processing task is used to disconnect the parent process from the child process. When an exit signal is received, disconnecting the connection between the parent process before the hot upgrade of the service request and the child process after the hot upgrade includes: using an asynchronous processing component to execute the asynchronous processing task. The exit signal is sent by the client or the server; the asynchronous processing component includes a first processing component and a second processing component; executing the asynchronous processing task using the asynchronous processing component includes: If the first exit signal from the client is received first, the connection between the parent process and the child process is disconnected using the first processing component. If a second exit signal is received from the server first, the connection between the parent process and the child process is disconnected using the second processing component.
2. The method according to claim 1, wherein, The second exit signal is issued after the subprocess has finished processing the service request or after the service request has timed out.
3. The method of claim 1, wherein, Exiting the parent process includes: The parent process is identified according to a first identifier, and the child process is identified according to a second identifier; wherein the parent process is pre-marked in the process management module using the first identifier, and the child process is pre-marked in the process management module using the second identifier; Control the parent process to be in an exited state, and control the child process to be in a running state.
4. The method of claim 3, wherein, After exiting the parent process, the process also includes: Receive the return value after the parent process exits; the return value includes a first return value and a second return value; If the return value is the first return value, then the parent process is controlled to remain in the exit state; If the return value is the second return value, then the parent process is launched.
5. The method according to any one of claims 1 to 4, wherein, The port information includes outbound port information and inbound port information; The subprocess handles subsequent service requests based on the port information and the file descriptor information, including: The subprocess generates an outbound port based on the outbound port information and an inbound port based on the inbound port information. The subprocess generates a socket file based on the file descriptor information; The subsequent service requests are processed using the Socket file, the outbound port, and the inbound port.
6. The method according to any one of claims 1-4, wherein the subprocess processes subsequent service requests based on the port information and the file descriptor information, comprising: Receive the target service request from the target process; Establish a connection between the child process and the target process; The port information and file descriptor information are transferred to the target process so that the target process can process the subsequent service requests based on the port information and file descriptor information.
7. A gateway hot upgrade system, comprising a control module and a processing module: The control module is used to disconnect the connection between the parent process before the hot upgrade and the child process after the hot upgrade when an exit signal is received; wherein... The service request is used to establish a connection between the child process after the hot upgrade and the parent process before the hot upgrade; the child process is used to receive the port information and file descriptor information transferred by the parent process after the connection is established. The processing module is used to exit the parent process and use the child process to process subsequent service requests based on the port information and the file descriptor information. The system further includes a generation module for generating an asynchronous processing task for the service request; the asynchronous processing task is used to disconnect the connection between the parent process and the child process; the control module is specifically used to execute the asynchronous processing task using the asynchronous processing component. The exit signal is sent by the client or the server; the asynchronous processing component includes a first processing component and a second processing component; the control module is specifically used to: if the first exit signal sent by the client is received first, then use the first processing component to disconnect the connection between the parent process and the child process; if the second exit signal sent by the server is received first, then use the second processing component to disconnect the connection between the parent process and the child process.
8. A gateway, comprising: processor; as well as Stored program memory, The program includes instructions that, when executed by the processor, cause the processor to perform the steps of the method according to any one of claims 1-6.
9. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the steps of the method according to any one of claims 1-6.
10. A computer program product, wherein, The computer program product includes a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-6.
Citation Information
Patent Citations
Passing Listener Sockets Between Web Server Processes
US20190327332A1
Transfer of socket ownership between processes
WO2019175625A2