Gateway, and gateway hot upgrade method and system
By disconnecting the parent process from the child process during the gateway hot upgrade, and using the child process to process the information of the parent process, the problem of the parent process not receiving a reply within the waiting time is solved, a graceful exit is achieved, and the gateway service is ensured. high availability.
Patent Information
- Application Number
- PCT/CN2024/087329
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-04-17
- Filing Date
- 2024-04-11
- Publication Date
- 2024-10-24
AI Technical Summary
In the existing gateway hot upgrade solution, the parent process exits without receiving a reply within the waiting time, which cannot guarantee the graceful exit of the process and affects service availability.
By disconnecting the parent process and the child process when receiving an exit signal, the child process receives the port information and file descriptor information transferred by the parent process, and uses this information to process service requests to ensure that the parent process exits gracefully.
It reduces the situation where service requests do not receive a reply within the waiting time, realizes the graceful exit of the parent process, and ensures the high availability and stability of the gateway service.
Smart Images

Figure CN2024087329_24102024_PF_FP_ABST
Abstract
Description
Gateway, gateway hot upgrade method and system
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on April 17, 2023, with application number 202310436793.0 and invention name “Gateway, Gateway Hot Upgrade Method and System”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of cloud computing, and in particular to a gateway, a gateway hot upgrade method and a system. Background Art
[0003] This section is intended to provide a background or context to the embodiments of the present application that are recited in the claims. No admission is made that the description herein is prior art by virtue of its inclusion in this section.
[0004] As a critical facility for carrying inbound and outbound traffic on a machine, the gateway requires hot-upgrade functionality during application redeployment or upgrades to ensure unimpeded inbound and outbound traffic, thereby preventing interruptions to service requests and responses on the machine and ensuring service availability. In existing gateway hot-upgrade solutions, after receiving the FD (File Descriptor) transmitted by the parent process, the child process sends a message to the parent process, instructing it to exit. However, the parent process mechanically waits for a period of time before exiting. This can lead to the possibility of exiting without receiving a response within the waiting period, thus failing to guarantee an elegant process exit.
[0005] Summary of the Invention
[0006] The embodiments of the present application provide a gateway, a gateway hot upgrade method and a system, which can at least optimize the process of parent process exit and enable the parent process to exit gracefully.
[0007] According to one aspect of the present application, a gateway hot upgrade method is also provided, including: upon receiving an exit signal, disconnecting 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 establishing the connection; exiting the parent process, and using the child process to process the service request according to the port information and the file descriptor information.
[0008] According to another aspect of the present application, a gateway hot upgrade system is also provided, including 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 of the service request when receiving an exit signal; 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 establishing the connection; 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.
[0009] According to another aspect of the present application, a gateway is also provided, which performs gateway hot upgrade according to the above method steps.
[0010] According to another aspect of the present application, an electronic device is provided, comprising: a processor; and a memory storing a program, wherein the program comprises instructions, which, when executed by the processor, enable the processor to perform the above method.
[0011] According to another aspect of the present application, a non-transitory computer-readable storage medium storing computer instructions is further provided, wherein the computer instructions are used to enable the computer to execute the steps of the above method.
[0012] According to another aspect of the present application, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the above method steps are implemented.
[0013] Beneficial effects of the embodiments of the present application:
[0014] In an embodiment of the present application, when an exit signal is received, the connection between the parent process before the hot upgrade of the service request 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 establishing the connection; exit the parent process, and use the child process to process the service request according to the port information and the file descriptor information. When an exit signal is received, the present application disconnects the connection between the parent process before the hot upgrade and the child process after the hot upgrade of the service request, and performs a disconnection operation between the parent process and the child process based on the exit signal, thereby realizing control over the parent process exit process, thereby reducing situations where the service request does not receive a reply within the waiting time and the parent process exits, and further ensuring the elegant exit of the parent process.
[0015] The details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the multiple drawings represent the same or similar components or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments disclosed in this application and should not be construed as limiting the scope of this application.
[0017] FIG1 is a flow chart of a gateway hot upgrade method according to an embodiment of the present application;
[0018] FIG2 is a schematic diagram of an existing gateway hot upgrade method according to an embodiment of the present application;
[0019] FIG3 is a schematic diagram of a gateway hot upgrade method according to an embodiment of the present application;
[0020] FIG4 is a structural block diagram of an exemplary electronic device that can be used to implement the embodiments of the present application. DETAILED DESCRIPTION
[0021] The following describes embodiments of the present application in more detail with reference to the accompanying drawings. Although certain embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be construed as being limited to the embodiments described herein. Instead, these embodiments are provided to provide a more thorough and complete understanding of the present application. It should be understood that the drawings and embodiments of the present application are for illustrative purposes only and are not intended to limit the scope of protection of the present application.
[0022] In existing gateway hot upgrade solutions, as shown in Figure 2, both parent and child processes create a socket when they start 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 applications deployed for the first time, since they don't have a parent process, this UDS file can be created. However, for subsequent hot upgrades, since the child process has a parent process, it can communicate with the parent process by directly opening the parent's UDS file. In this solution, the following steps are explained based on the scenario where the child process has a parent process during the hot upgrade.
[0023] 1. Before the child process proceeds to the bind process, it needs to first send a shutDownParent message (an instruction for shutting down the parent process) to the parent process. After receiving the message, the parent process stops listening and closes the socket. This can make the new connection fail quickly and prevent the new connection from entering the accept queue.
[0024] 2. After receiving the response from step 1, the child process sends a passListenSocket (instructions for passing the listening socket) message, which carries the FD type to be transmitted. For example, if the gateway currently only opens inbound and outbound ports to the outside world, the inbound and outbound ports bound to the parent process and the FD can be transferred to the child process. If there is a new open port in the future, the transmission can continue.
[0025] 3. When TLS (Transport Layer Security) encryption is turned on, the gateway will be in a certain state.
[0026] 4. After the child process receives the FD transmitted by the parent process, it can accept new connections. The child process sends a drainListenerAndkillParent message (an instruction used to notify the parent process to exit) to allow the parent process to exit gracefully. At this point, the remaining work of the parent process is to complete the processing of the established connection. A certain amount of time is reserved here for this processing. After processing, the FD is cleaned up to prevent leakage, and then the parent process exits gracefully.
[0027] In the above solution, the parent process just mechanically waits for a period of time and then exits. It is possible that the request will exit without receiving a response within the waiting time, and the graceful exit of the process cannot be guaranteed.
[0028] The gateway itself needs to have high availability characteristics to serve as an infrastructure to ensure the network communication reliability of the components it is responsible for proxying. Therefore, based on the above background, this application now proposes a gateway, gateway hot upgrade method and system, which can optimize the parent process exit process and enable the parent process to exit gracefully.
[0029] The terms involved are explained below.
[0030] Hot upgrade: refers to the act of upgrading without interrupting application services.
[0031] Gateway software: Software that translates and proxies network requests. It runs on a regular computer or server, enabling communication between different networks or protocols. Gateway software typically includes routers, firewalls, proxy servers, and other components, fulfilling various gateway functions.
[0032] Graceful exit: The normal termination or closure of a program, system, or network connection. This type of exit can avoid exceptions or errors when the program or system ends, avoid data loss or corruption, and thus ensure data integrity and security.
[0033] This embodiment provides a gateway hot upgrade method. This method can be applied to a server, which can provide gateway services to clients based on client service requests. Gateway services can be implemented using gateway software. Figure 1 is a flow chart of the gateway hot upgrade method according to an embodiment of the present application. The method steps involved in Figure 1 are described below.
[0034] Step S102, when an exit signal is received, disconnect the connection between the parent process before the hot upgrade of the service request 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 the port information and file descriptor information transferred by the parent process after establishing the connection.
[0035] In this step, a service request may be sent from the client to the gateway, requesting service from the server via the gateway. It should be noted that the gateway may be a hardware device or implemented via gateway software. This service request may be used to establish a connection between the child process after the hot upgrade and the parent process before the hot upgrade. After establishing this connection, the child process receives the port information and file descriptor information transferred from the parent process.
[0036] Among them, the port information is used to determine the port transferred from the parent process to the child process. The port can be used to implement functions such as receiving data packets, filtering and security checks on data packets, performing network address translation, and sending data packets. The specific port used can be determined according to actual needs, and the embodiments of the present application do not specifically limit this. In computer network programming, Socket is a communication mechanism that allows different processes to communicate on the network. Socket usually uses file descriptors (FD) to operate. FD is an integer, which is a unique identifier assigned by the operating system kernel to each open file or device. In Socket programming, Socket FD refers to the file descriptor of a Socket connection, which is an integer used to identify a Socket connection. Socket FD can be used to send and receive data, as well as perform other Socket operations, such as setting Socket options, closing Socket connections, etc. In Socket programming, Socket FD is usually created through Socket functions.
[0037] In this step, the process can be an instance of a running program. A process is the basic execution unit in a computer system, containing information such as program code, data, and execution status. Processes typically communicate using the Socket mechanism, and each process can create one or more Socket connections for communicating with other processes. Communication between processes can be synchronous or asynchronous, and data can be sent and received via Sockets or through other communication mechanisms. In this step, the parent process and child process have a hierarchical relationship. The child process can be a copy of the parent process, and they share some resources, such as port information and file descriptor information, but some resources between them can also be independent. The process that existed before the gateway hot upgrade is used as the parent process, and the process used after the gateway hot upgrade that shares information such as port information and file descriptor information with the parent process is used as the child process.
[0038] In this step, the exit signal is used to determine the time to start executing the asynchronous processing task. The exit signal can be sent in the form of a message or instruction. A message can be information transmitted during the communication process, for example, in the form of text, images, audio, video, etc. Instructions 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 based on actual needs and is not specifically limited in this embodiment of the application.
[0039] In this step, when an exit signal is received, the operation of disconnecting the parent process from the child process is initiated through the exit signal, thereby controlling the disconnection operation and reducing the situation where the parent process exits without receiving a response within the waiting time.
[0040] Step S104: exit the parent process, and use the child process to process the service request according to the port information and the file descriptor information.
[0041] In this step, exiting the parent process means terminating the currently running parent process and releasing occupied system resources. The child process is used to process the service request according to the port information and the file descriptor information, wherein the child process can be used to execute part or all of the work of the exited parent process.
[0042] It should be noted here that through gateway hot upgrade, all or part of the work handled by the parent process can be transferred to the child process for processing.
[0043] It should also be noted that if a child process does not have a corresponding parent process, it means that the process is deployed for the first time, and a UDS file for the process can be created. The port information and file descriptor information of the process are obtained through the newly created UDS file.
[0044] In an embodiment of the present application, when an exit signal is received, the connection between the parent process before the hot upgrade of the service request 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 establishing the connection; exit the parent process, and use the child process to process the service request according to the port information and the file descriptor information. When an exit signal is received, the present application disconnects the connection between the parent process before the hot upgrade and the child process after the hot upgrade of the service request, and performs a disconnection operation between the parent process and the child process based on the exit signal, thereby realizing control over the parent process exit process, thereby reducing situations where the service request does not receive a reply within the waiting time and the parent process exits, and further ensuring the elegant exit of the parent process.
[0045] In one possible implementation, the solution also includes 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; 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, which can be performed according to the following steps: using an asynchronous processing component to execute the asynchronous processing task.
[0046] In this possible implementation, after receiving a service request, the gateway generates a corresponding asynchronous processing task for each service request. For example, the asynchronous processing task can be a Tokio (an asynchronous I / O (Input / Output) runtime library that provides an efficient way to write asynchronous, concurrent, and scalable network applications) task, which is used to disconnect the parent process from the child process.
[0047] It should be noted that asynchronous processing tasks can refer to coroutines, which can be paused and resumed during execution, thereby realizing task switching and scheduling.
[0048] 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. Therefore, 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.
[0049] The asynchronous processing component can be used to perform asynchronous processing tasks, thereby disconnecting the parent process from the child process. The asynchronous processing component can be implemented based on the select macro. Select is a system call used to wait for data on multiple file descriptors. The select macro is a function that encapsulates the select system call and is used to wait for data on a set of file descriptors.
[0050] In this step, the asynchronous processing component is used to execute the asynchronous processing task only when the exit signal is received, so that the operation of disconnecting the connection between the parent process and the child process can be initiated by the exit signal, thereby realizing the control of the disconnection operation and reducing the situation where the parent process exits without receiving a reply within the waiting time.
[0051] In one possible implementation, the exit signal is sent by the client or by the server; the asynchronous processing component includes a first processing component and a second processing component; the asynchronous processing task is executed using the asynchronous processing component, which can be performed according to the following steps: if the first exit signal sent by the client is received first, the first processing component is used to disconnect the connection between the parent process and the child process; if the second exit signal sent by the server is received first, the second processing component is used to disconnect the connection between the parent process and the child process.
[0052] In this possible implementation, the client and server can be processes running on different computers, communicating over a network. The client sends a request message to the server, which receives and processes the request message and ultimately returns a response message to the client.
[0053] When performing a hot upgrade of the gateway, the client or server can control the exit of the parent process of the hot upgrade process. For example, when the client needs to pause the hot upgrade and control the parent process to exit early, it will send an exit signal, and the exit signal issued by the client will be used as the first exit signal. During the normal hot upgrade process, the server can control the exit timing of the parent process by sending an exit signal, and the exit signal issued by the server will be used as the second exit signal. For example, in one possible implementation, this second exit signal can be issued after the child process completes the connection request or after the connection request times out, thereby ensuring the graceful exit of the parent process.
[0054] If the first exit signal sent by the client is received before the second exit signal sent by the server is received, the first processing component is used to perform an asynchronous processing task, thereby disconnecting the connection between the parent process and the child process. If the second exit signal sent by the server is received before the first exit signal sent by the client, the second processing component is used to perform an asynchronous processing task, thereby disconnecting the connection between the parent process and the child process.
[0055] In this step, whichever of the first and second processing components is responded to first will process the corresponding task according to the received exit signal, thereby controlling the disconnection timing of the parent process and the child process, and thus ensuring the graceful exit of the parent process.
[0056] It should be noted that the first processing component or the second processing component can be an independent module or component in the software system, which can be developed, tested, deployed and maintained separately; it can have a clearly defined interface and function, and can be called and used by other components or systems.
[0057] Considering that in the process management module, when a parent process exits, it may be identified as an abnormal exit, etc., the exited parent process is easily restarted, resulting in a waste of resources. In one possible embodiment, 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 with the first identifier in the process management module, and the child process is pre-marked with the second identifier in the process management module; controlling the parent process to be in an exit state, and controlling the child process to be in a running state.
[0058] In this possible implementation, the process management module can be used to manage 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 application does not specifically limit this.
[0059] The first identifier and the second identifier can be selected according to actual needs, for example, they can include special characters, numbers, character strings, etc. The first identifier is used to mark the parent process in advance, and the second identifier is used to mark the child process, so that the parent process and the child process can be distinguished. Then, the parent process is identified according to the first identifier, and the child process is identified according to the second identifier, and the parent process is controlled to be in the exit state and the child process is controlled to be in the running state.
[0060] For example, in one possible implementation, the process management module is implemented by Systemd (a process management method based on dependency). Systemd can automatically start and stop system services, and can establish dependencies between services to ensure that they are started and stopped in the correct order. If the gateway process is managed by Systemd, and Systemd has the function of adding the managed processes to the daemon list (for example, this application can be implemented by adding rustyncproxy.service to / usr / lib / systemd / system / ), this will enable the gateway process to be quickly started in time to ensure the high availability of the gateway process when an abnormal exit occurs. However, this mechanism also brings considerable trouble to the hot upgrade of this application. Consider such a situation: the gateway parent process is guarded by Systemd. When the gateway child process connects the UDS address of the parent process, the parent process gracefully exits after transferring the FD. At this time, Systemd detects that the parent process has exited and restarts it. Such a restart may affect the hot upgrade process.
[0061] In order to make the parent process exit and not be pulled up again, when using Systemd to implement the process management module, when adding the managed process to the Systemd daemon list, you can configure the process service template name to rustyncproxy@.service, that is, add an @ character after the service name. After that, the parent process is named rustyncproxy@0.service; the child process is named rustyncproxy@1.service; in this way, during hot upgrades, the parent process and the child process can be distinguished by the different parameters after @.
[0062] To ensure that Systemd can quickly restart the gateway process when it unexpectedly crashes, in one possible implementation, after exiting the parent process, the following steps can also be performed:
[0063] 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 continue in the exit state; if the return value is the second return value, start the parent process.
[0064] In this possible implementation, a return value will be sent after the parent process exits, and the return value includes a first return value and a second return value, wherein the first return value can be returned when the parent process exits normally, for example, the first return value can be 0; the second return value can be returned when the parent process exits abnormally, for example, the second return value can be an abnormal prompt parameter, such as termination signal intelligence (SIGTERM), etc.
[0065] In this step, the return value is differentiated to obtain the first return value and the second return value, so that if the parent process exits normally, the parent process is controlled to continue to be in the exit state, so that it will not be restarted repeatedly during hot upgrades; if the parent process exits abnormally, the parent process is pulled up according to the second return value to alleviate the problem of parent process exit caused by unexpected circumstances.
[0066] The port information may include multiple types of port information. In one possible implementation, the port information includes outbound port information and inbound port information; processing the service request using the child process based on the port information and the file descriptor information may be performed as follows:
[0067] The child process is used to generate an outbound port according to the outbound port information and an inbound port according to the inbound port information; the child process is used to generate a Socket file according to the file descriptor information; and the Socket file, the outbound port and the inbound port are used to process the service request.
[0068] In this possible implementation, an inbound port refers to the port on the gateway device used to receive packets from the external network. An outbound port refers to the port on the gateway device used to send packets to the external network. Both of these ports can also be used for forwarding, routing, filtering, security checks, and address translation. They are essential components of the gateway device and play a crucial role in protecting internal network security and enabling network communications.
[0069] 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 information, inbound port information, and socket file based on the received information, thereby implementing some or all of the functions that the parent process can implement.
[0070] In this step, the port information may include various types of port information, which is set according to actual needs and is not specifically limited in the embodiments of the present application.
[0071] After the parent process exits, the child process can serve as the new parent process during the subsequent gateway hot upgrade process, transferring the port information and file descriptor information to the new child process. Therefore, in one possible implementation, the child process can process the service request based on the port information and the file descriptor information by following the steps below:
[0072] 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 as to utilize the target process to process the service request according to the port information and the file descriptor information.
[0073] In this possible implementation, when the child process serves as the parent process in the subsequent gateway hot upgrade process, the target process can serve as a new child process, and the service request of the target process can serve 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 allowing the gateway to continuously perform hot upgrades.
[0074] The implementation of this method is described below with reference to a specific embodiment.
[0075] Referring to the schematic diagram of the gateway hot upgrade method shown in FIG3 , the solution adopted by this application is to use two processes to coexist for a period of time to ensure the transmission of socket FD between the new process (i.e., child process) and the old process (i.e., parent process), so that network requests will not be interrupted during the hot upgrade. The new process of the gateway will try to connect to a specific UDS address at the beginning of the hot upgrade. If the old process exists, it will connect to the socket file previously created by the old process, and the inbound and outbound socket FDs created by the old process can be transferred to the new process. If the old process does not exist, the connection is unsuccessful, which proves that this is the first deployment of the gateway service or there is a Unix domain socket communication error. Retry and timeout strategies are required to ensure that the gateway service can continue to run.
[0076] When the new process receives the inbound and outbound socket FDs transferred from the old process, it creates new inbound and outbound socket FDs based on these FDs and completes the bind operation. New network requests passing through the gateway are then transferred to the new process for service. The old process does not immediately terminate; it must wait for previously established requests to be responded to (or time out) before terminating. The new process can then serve as the parent process in subsequent hot upgrades, connecting to the new child process and performing a graceful exit, repeating the above process steps.
[0077] In the above steps, the old process must first ensure that the FD is transferred to the new process when receiving the new process's connect, and then it needs to immediately stop connecting to its own inbound and outbound sockets to ensure that no new client connections come. This can be achieved by using the select macro to handle the exit signal drain and connect asynchronous tasks.
[0078] Secondly, the old process needs to wait for the previously connected request to be processed. This is achieved by the gateway service assigning a tokio processing task (similar to a coroutine) to each request. Each task will be assigned two asynchronous select macros. The first select macro is used to handle the client's early exit; the second select macro is used to handle the exit signal drain; whichever asynchronous select macro is responded to first will execute the corresponding task: the select macro of the exit signal drain is issued when the old process wants to perform an elegant exit. The corresponding processing task is to wait for the request to receive a reply or release the connect connection after a timeout response. In this way, the request that has previously established a connection with the old process needs to wait for it to receive a reply or time out and return.
[0079] An embodiment of the present application provides a gateway hot upgrade method, which can ensure that service requests that have previously established a connection with the old process need to wait for it to receive a reply or time out and return, and can also ensure that new requests are sent to the new process for processing, so that business requests or responses will not be interrupted during the gateway upgrade, ensuring the high availability and high stability of the gateway.
[0080] An embodiment of the present application 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 before the hot upgrade and the child process after the hot upgrade of the service request when receiving an exit signal; 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 establishing the connection; 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.
[0081] In an embodiment of the present application, when an exit signal is received, the connection between the parent process before the hot upgrade of the service request and the child process after the hot upgrade is disconnected, and the disconnection operation between the parent process and the child process is performed based on the exit signal to realize the control of the parent process exit process, thereby reducing the situation where the service request does not receive a reply within the waiting time and the parent process exits, and further ensuring the elegant exit of the parent process.
[0082] In a possible implementation, it 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; and the control module is specifically used to: execute the asynchronous processing task using an asynchronous processing component.
[0083] In one possible implementation, the exit signal is sent by the client or by 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.
[0084] In a possible implementation manner, the second exit signal is issued after the child process completes processing the connection request or after a timeout response to the connection request.
[0085] In one possible embodiment, the processing module is used to: identify the parent process based on a first identifier, and identify the child process based on a second identifier; wherein the parent process is pre-marked with the first identifier in the process management module, and the child process is pre-marked with the second identifier in the process management module; control the parent process to be in an exit state, and control the child process to be in a running state.
[0086] In one possible implementation, the processing module is further used to: 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 continue to be in the exit state; if the return value is the second return value, start the parent process.
[0087] In one possible implementation, the port information includes outbound port information and inbound port information; the processing module is used to: use the child process to generate an outbound port based on the outbound port information, and generate an inbound port based on the inbound port information; use the child process to generate a Socket file based on the file descriptor information; and use the Socket file, the outbound port, and the inbound port to process the service request.
[0088] In one possible embodiment, the processing module is also used to: 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 as to use the target process to process the service request according to the port information and the file descriptor information.
[0089] An embodiment of the present application further provides an electronic device, comprising: 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, wherein the computer program, when executed by the at least one processor, causes the electronic device to perform a method according to an embodiment of the present application.
[0090] An embodiment of the present application further provides a gateway, wherein the gateway performs a gateway hot upgrade according to the above method steps.
[0091] An embodiment of the present application further provides a non-transitory computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to perform a method according to an embodiment of the present application.
[0092] An embodiment of the present application further provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor of a computer, the computer is used to cause the computer to perform a method according to an embodiment of the present application.
[0093] With reference to Figure 4, the structural block diagram of the electronic device 400 that can be used as the server or user of the present application will now be described, which is an example of a hardware device that can be applied to various aspects of the present application. The electronic device is intended to represent various forms of digital electronic computer equipment, such as laptop computers, desktop computers, workbenches, 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 processing, cellular phones, smart phones, wearable devices and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.
[0094] As shown in Figure 4, 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. In RAM 403, various programs and data required for the operation of device 400 can also be stored. Computing unit 401, ROM 402, and RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to bus 404.
[0095] Multiple components within electronic device 400 are connected to I / O interface 405, including an input unit 406, an output unit 407, a storage unit 408, and a communication unit 409. Input unit 406 can be any type of device capable of inputting information into electronic device 400. Input unit 406 can receive input numeric or character information and generate key signal inputs related to user settings and / or function control of the 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, a speaker, a video / audio output terminal, a vibrator, and / or a printer. Storage unit 408 may include, but is not limited to, a magnetic disk or an optical disk. Communication unit 409 allows electronic device 400 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks and may include, but is not limited to, a modem, a network card, an infrared communication device, a wireless communication transceiver and / or a chipset, such as a Bluetooth device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.
[0096] The computing unit 401 may be a variety of general and / or special 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 dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 401 performs the various methods and processes described above. For example, in some embodiments, the aforementioned method may be implemented as a computer software program that is tangibly included in a machine-readable medium, such as a storage unit 408. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 400 via the ROM 402 and / or the communication unit 409. In some embodiments, the computing unit 401 may be configured to perform the aforementioned method in any other appropriate manner (e.g., by means of firmware).
[0097] The program code for implementing the method of the embodiment of the present application can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0098] In the context of the present application embodiment, machine-readable medium can be a tangible medium that can contain or store a program for use by an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable medium can include but is not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device or any suitable combination of the foregoing.
[0099] It should be noted that the term "including" and its variations used in the embodiments of the present application are open inclusions, that is, "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 other embodiment"; the term "some embodiments" means "at least some embodiments". The modifications of "one" and "multiple" mentioned in the embodiments of the present application are illustrative and not restrictive. Those skilled in the art should understand that unless the context clearly indicates otherwise, it should be understood as "one or more".
[0100] 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 this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0101] The various steps described in the method implementation schemes provided in the embodiments of the present application can be performed in different orders and / or in parallel. In addition, the method implementation schemes may include additional steps and / or omit the steps shown. The scope of protection of the present application is not limited in this respect.
[0102] The term "embodiment" in this specification refers to specific features, structures or characteristics described in conjunction with the embodiment that can be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. The various embodiments in this specification are described in a related manner, and the same or similar parts between the various embodiments are referenced to each other. In particular, for the device, equipment, and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts are referred to the partial description of the method embodiment.
[0103] The above-described embodiments merely represent several implementation methods of the present application. 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 a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.
Claims
1. A gateway hot upgrade method, comprising: When receiving the exit signal, disconnect the connection between the parent process before the hot upgrade of the service request 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 the port information and file descriptor information transferred by the parent process after establishing the connection; Exit the parent process, and use the child process to process the service request according to the port information and the file descriptor information.
2. The method according to claim 1, wherein: Also includes: Generate 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; When the exit signal is received, the connection between the parent process before the hot upgrade of the service request and the child process after the hot upgrade is disconnected, including: using the asynchronous processing component to execute the asynchronous processing task.
3. The method according to claim 2, wherein: 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; and executing the asynchronous processing task using the asynchronous processing component includes: If a first exit signal sent by the client is received first, disconnecting the connection between the parent process and the child process by using the first processing component; If the second exit signal sent by the server is received first, the second processing component is used to disconnect the connection between the parent process and the child process.
4. The method according to claim 3, wherein: The second exit signal is issued after the child process completes processing the connection request or after the connection request times out.
5. The method according to claim 1, wherein: Exit the parent process, including: 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 a process management module by the first identifier, and the child process is pre-marked in the process management module by the second identifier; The parent process is controlled to be in an exit state, and the child process is controlled to be in a running state.
6. The method according to claim 5, wherein: After exiting the parent process, it also includes: 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, controlling the parent process to continue to be in the exit state; If the return value is the second return value, the parent process is started.
7. The method according to any one of claims 1 to 6, wherein: The port information includes outbound port information and inbound port information; Processing the service request using the child process according to the port information and the file descriptor information includes: Using the child process to generate an outbound port according to the outbound port information, and generating an inbound port according to the inbound port information; Using the child process to generate a Socket file according to the file descriptor information; The service request is processed using the Socket file, the outbound port and the inbound port.
8. The method according to any one of claims 1 to 6, using the child process to process the service request according to the port information and the file descriptor information, comprising: Receive a target service request from a target process; Establishing a connection between the subprocess and the target process; The port information and the file descriptor information are transferred to the target process, so that the target process processes the service request according to the port information and the file descriptor information.
9. 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 of the service request when receiving the exit signal; 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 establishing the connection; 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.
10. A gateway, wherein: The gateway performs gateway hot upgrade according to the method steps described in any one of claims 1-8.
11. An electronic device, comprising: processor; as well as Memory for storing programs, The program comprises instructions, which, when executed by the processor, cause the processor to perform the method steps according to any one of claims 1 to 8.
12. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method steps according to any one of claims 1-8.
13. A computer program product, wherein: The computer program product comprises a computer program, and when the computer program is executed by a processor, the method steps according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Smooth upgrade method and device for application program
CN108241496A
Gateway control program graceful upgrading method based on father and child process transmission descriptors
CN113986286A
Gateway upgrading method and device
CN114553693A
Gateway and gateway hot upgrade method and system
CN116599796A
Technique for updating program being executed
US20130111454A1
