File synchronization method, file update method, device, electronic equipment and medium
By determining the file status of the target configuration file and matching the front-end service information, and using hot file updates, the problem of low configuration file synchronization efficiency caused by different front-end application development models is solved, achieving efficient configuration file synchronization and normal operation of the front-end application.
Patent Information
- Application Number
- CN202210421413.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-21
- Publication Date
- 2026-02-17
- Estimated Expiration
- 2042-04-21
AI Technical Summary
Because different front-end application development models are not entirely the same, the synchronization efficiency of configuration files is extremely low, which affects the normal operation and use of front-end applications.
By determining the file status of the target configuration file, matching the front-end service information, and synchronizing the configuration file to the corresponding server according to the synchronization type, hot file updates can be achieved, including asynchronous synchronization, file stream push, and configuration file pooling.
It improves the synchronization efficiency of configuration files, ensures the normal operation and use of front-end applications, and avoids data loss problems caused by cold updates.
Smart Images

Figure CN116975012B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present disclosure relate to the technical field of computer technology, and specifically to a file synchronization method, a file updating method, an apparatus, an electronic device, and a medium. BACKGROUND
[0002] With the rapid development of Internet technology, the number of front-end applications is increasing, thereby requiring a large number of configuration files corresponding to the front-end applications to be deployed to enable the front-end applications to run normally. In particular, when the front-end applications are updated, it is necessary to ensure that the corresponding configuration files are timely and accurately synchronized to the front-end applications to implement the front-end application update. Currently, when synchronizing the front-end configuration files, the commonly used manner is to independently update and synchronize the corresponding configuration files according to the business requirements of the front-end applications.
[0003] However, when the above manner is used, the following technical problems often exist:
[0004] Since the development modes of different front-end applications are often different, it is necessary to separately update and synchronize the configuration files for front-end applications of different architectures, which results in extremely low synchronization efficiency of the configuration files, thereby affecting the normal operation and use of the front-end applications. SUMMARY
[0005] The summary of the present disclosure is used to introduce the concepts in a brief form, which will be described in detail in the following detailed description. The summary of the present disclosure is not intended to identify key or essential features of the claimed technical solutions, nor is it intended to be used to limit the scope of the claimed technical solutions.
[0006] Some embodiments of the present disclosure propose a file synchronization method, a file updating method, an apparatus, an electronic device, and a medium to solve one or more of the technical problems mentioned in the background section.
[0007] In a first aspect, some embodiments of the present disclosure provide a file synchronization method, which comprises: determining a file state of a target configuration file; in response to determining that the file state represents that the target configuration file is updated, determining front-end service information matched with the target configuration file; and according to a synchronization type corresponding to the target configuration file, synchronizing the target configuration file to at least one first target server corresponding to the front-end service information, so that the at least one first target server performs file hot updating according to the target configuration file.
[0008] Optionally, the synchronizing the target configuration file to the at least one first target server corresponding to the front-end service information according to the synchronization type corresponding to the target configuration file comprises: in response to determining that the synchronization type is a first synchronization type, determining a synchronization manner of the target configuration file; and synchronizing the target configuration file to the at least one first target server corresponding to the front-end service information according to the synchronization manner.
[0009] Optionally, the synchronizing the target configuration file to the at least one first target server corresponding to the front-end service information according to the synchronization manner comprises: in response to determining that the synchronization manner is a first synchronization manner, synchronizing, for each of the at least one first target server, the target configuration file to a target directory included in the first target server by a synchronization command.
[0010] Optionally, the synchronizing the target configuration file to the at least one first target server corresponding to the front-end service information according to the synchronization manner comprises: in response to determining that the synchronization manner is a second synchronization manner, creating a file stream push pipeline; and pushing the target configuration file to the at least one first target server corresponding to the front-end service information by the file stream push pipeline.
[0011] Optionally, the synchronizing the target configuration file to the at least one first target server corresponding to the front-end service information according to the synchronization type corresponding to the target configuration file comprises: in response to determining that the synchronization type is a second synchronization type, adding the target configuration file to a configuration file pool; in response to determining that there is a configuration file in the configuration file pool, starting the configuration file pool; and in response to determining that the configuration file pool is started successfully, pushing the target configuration file stored in the configuration file pool to the at least one first target server corresponding to the front-end service information.
[0012] In a second aspect, some embodiments of the present disclosure provide a file synchronization apparatus, the apparatus comprising: a first determination unit configured to determine a file state of a target configuration file; a second determination unit configured to, in response to determining that the file state indicates that the target configuration file is updated, determine front-end service information matched with the target configuration file; and a synchronization unit configured to synchronize the target configuration file to at least one first target server corresponding to the front-end service information according to a synchronization type corresponding to the target configuration file, so that the at least one first target server performs file hot update according to the target configuration file.
[0013] Optionally, the above synchronization unit is further configured to: in response to determining that the above synchronization type is a first synchronization type, determine the synchronization method of the above target configuration file; and synchronize the above target configuration file to at least one first target server corresponding to the above front-end service information according to the above synchronization method.
[0014] Optionally, the synchronization unit is further configured to: in response to determining that the synchronization method is the first synchronization method, for each of the at least one first target server, synchronize the target configuration file to the target directory contained in the first target server through a synchronization command.
[0015] Optionally, the above synchronization unit is further configured to: in response to determining that the above synchronization method is the second synchronization method, create a file stream push pipeline; and push the above target configuration file to at least one first target server corresponding to the above front-end service information through the above file stream push pipeline.
[0016] Optionally, the above synchronization unit is further configured to: in response to determining that the above synchronization type is a second synchronization type, add the above target configuration file to the configuration file pool; in response to determining that there is a configuration file in the above configuration file pool, start the above configuration file pool; in response to determining that the above configuration file pool has started successfully, push the above target configuration file stored in the above configuration file pool to at least one first target server corresponding to the above front-end service information.
[0017] Thirdly, some embodiments of this disclosure provide a file update method, which includes: obtaining a target configuration file, wherein the target configuration file is generated using the method described in the first aspect; and performing a hot file update on the configuration file to be updated based on the target configuration file.
[0018] Optionally, obtaining the target configuration file as described above includes: in response to the existence of a configuration file to be updated, obtaining the target configuration file corresponding to the configuration file to be updated.
[0019] Optionally, the above-mentioned configuration file to be updated is generated by the following steps: scanning the configuration files stored locally to obtain at least one candidate configuration file; in response to determining that there is a candidate configuration file with changed data among the at least one candidate configuration file, the candidate configuration file with changed data is determined as the above-mentioned configuration file to be updated.
[0020] Optionally, obtaining the target configuration file as described above includes: creating a file stream pull pipeline; and pulling the target configuration file from the second target server according to the file stream pull pipeline.
[0021] Optionally, the above-mentioned hot file update of the configuration file to be updated based on the target configuration file includes: determining the file path of the configuration file to be updated; determining the cache area corresponding to the configuration file to be updated based on the file path; clearing the data stored in the cache area; and loading the target configuration file into the cache area in response to determining that the cache area has been cleared.
[0022] Fourthly, some embodiments of this disclosure provide a file update apparatus, the apparatus comprising: an acquisition unit configured to acquire a target configuration file, wherein the target configuration file is generated using the method described in the first aspect; and a hot update unit configured to perform a file hot update on the configuration file to be updated based on the target configuration file.
[0023] Optionally, the above-mentioned acquisition unit is further configured to: in response to the existence of a configuration file to be updated, acquire the target configuration file corresponding to the configuration file to be updated.
[0024] Optionally, the above-mentioned configuration file to be updated is generated by the following steps: scanning the configuration files stored locally to obtain at least one candidate configuration file; in response to determining that there is a candidate configuration file with changed data among the at least one candidate configuration file, the candidate configuration file with changed data is determined as the above-mentioned configuration file to be updated.
[0025] Optionally, the aforementioned acquisition unit is further configured to: create a file stream pull pipeline; and pull the aforementioned target configuration file from the second target server according to the aforementioned file stream pull pipeline.
[0026] Optionally, the hot update unit is further configured to: determine the file path of the configuration file to be updated; determine the cache area corresponding to the configuration file to be updated based on the file path; clear the data stored in the cache area; and, in response to determining that the cache area has been cleared, load the target configuration file into the cache area.
[0027] Fifthly, some embodiments of this disclosure provide an electronic device, including: one or more processors; and a storage device having one or more programs stored thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the methods described in any of the implementations of the first and third aspects above.
[0028] Sixthly, some embodiments of this disclosure provide a computer-readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the methods described in any of the implementations of the first and third aspects above.
[0029] The above embodiments of this disclosure have the following beneficial effects: the file synchronization method of some embodiments of this disclosure improves the synchronization efficiency of configuration files, ensuring the normal operation and use of front-end applications. Specifically, the reason for the extremely low synchronization efficiency of configuration files corresponding to front-end applications is that different front-end applications often have different development models, so configuration files need to be updated and synchronized separately for front-end applications with different architectures, which leads to extremely low synchronization efficiency. Based on this, some embodiments of this disclosure first determine the file status of the target configuration file. Then, in response to determining that the file status indicates that the target configuration file has been updated, front-end service information matching the target configuration file is determined. Since when the configuration file is updated, the corresponding front-end services often need to be updated in a timely manner to ensure that the front-end services can be used normally, this disclosure determines the front-end service information matching the target configuration file when the target configuration file changes, thereby determining which front-end services need to be updated. Finally, according to the synchronization type corresponding to the target configuration file, the target configuration file is synchronized to at least one first target server corresponding to the front-end service information, so that the at least one first target server performs hot file updates according to the target configuration file. When dealing with a large user base, it's often necessary to deploy the front-end service across multiple servers to handle the surge in user access. Therefore, the target configuration file needs to be synchronized to all servers corresponding to the front-end service information. Furthermore, considering that cold updates (i.e., closing the server to load the configuration file) can lead to the loss of cached data and requested data, hot updates are adopted. This ensures that configuration files are replaced and updated while the system continues to operate normally. This approach abstracts the configuration file update requirements of front-end applications with different architectures, enabling automated configuration file synchronization and significantly improving synchronization efficiency. Attached Figure Description
[0030] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and elements are not necessarily drawn to scale.
[0031] Figure 1 This is a schematic diagram illustrating an application scenario of the file synchronization method according to some embodiments of this disclosure;
[0032] Figure 2 This is a flowchart of some embodiments of the file synchronization method according to this disclosure;
[0033] Figure 3This is a flowchart of some other embodiments of the file synchronization method according to this disclosure;
[0034] Figure 4 This is a schematic diagram illustrating an application scenario of a file update method according to some embodiments of this disclosure;
[0035] Figure 5 This is a flowchart of some embodiments of the document update method according to this disclosure;
[0036] Figure 6 This is a flowchart of some other embodiments of the document update method according to this disclosure;
[0037] Figure 7 These are schematic diagrams illustrating the structure of some embodiments of the document synchronization apparatus according to this disclosure;
[0038] Figure 8 These are schematic diagrams illustrating the structure of some embodiments of the document updating apparatus according to this disclosure;
[0039] Figure 9 This is a schematic diagram of the structure of an electronic device suitable for implementing some embodiments of the present disclosure. Detailed Implementation
[0040] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure 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 this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0041] It should also be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings. Unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other.
[0042] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0043] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0044] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0045] This disclosure will now be described in detail with reference to the accompanying drawings and embodiments.
[0046] Figure 1 This is a schematic diagram illustrating an application scenario of a file synchronization method according to some embodiments of this disclosure.
[0047] exist Figure 1 In the application scenario, firstly, the computing device 101 can determine the file status 103 of the target configuration file 102; secondly, in response to determining that the file status 103 indicates that the target configuration file 102 has been updated, the computing device 101 can determine the front-end service information 104 that matches the target configuration file 102; finally, the computing device 101 can synchronize the target configuration file 102 to at least one first target server 106 corresponding to the front-end service information 104 according to the synchronization type 105 corresponding to the target configuration file 102, so that the first target server among the at least one first target server 106 can perform a hot file update according to the target configuration file 102.
[0048] It should be noted that the aforementioned computing device 101 can be either hardware or software. When the computing device is hardware, it can be implemented as a distributed cluster consisting of multiple servers or terminal devices, or as a single server or a single terminal device. When the computing device is software, it can be installed within the hardware devices listed above. It can be implemented as, for example, multiple software programs or software modules used to provide distributed services, or as a single software program or software module. No specific limitations are made here.
[0049] It should be understood that Figure 1 The number of computing devices shown is merely illustrative. Any number of computing devices can be used depending on implementation needs.
[0050] Continue to refer to Figure 2 The diagram illustrates a flow 200 of some embodiments of a file synchronization method according to the present disclosure. The file synchronization method includes the following steps:
[0051] Step 201: Determine the file status of the target configuration file.
[0052] In some embodiments, the execution subject of the text synchronization method (e.g. Figure 1The computing device 101 shown can determine the file status of the target configuration file. The file status can be used to characterize the current state of the target configuration file. For example, the file status can be, but is not limited to, any of the following: "Being Updated," "Executing," and "Execution Completed." The "Being Updated" status indicates that the target configuration file is being updated. The "Executing" status indicates that the configuration items contained in the target configuration file are being executed. The "Execution Completed" status indicates that the configuration items contained in the target configuration file have finished executing. The target configuration file can be a configuration file corresponding to a front-end application, used to ensure the normal operation of the front-end application.
[0053] As an example, the aforementioned execution entity can query the target database to determine the file status of the target configuration file. This target database can be a database that stores the correspondence between the target configuration file and its corresponding front-end service information, as well as the file status of the target configuration file. The aforementioned front-end service information can be information corresponding to the functions included in the front-end application. For example, a record in the target database could be [Target Configuration File Identifier: F00001, Target Configuration File Address: URL1, Front-end Service Identifier: S0101, Front-end Application Service Address: URL2, Target Configuration File Status: "Updated"].
[0054] Optionally, the executing entity can obtain the target configuration file from the target file system based on the target configuration file address. The target file system can be a file system used to store configuration files.
[0055] Step 202: In response to determining that the file status indicates the target configuration file has been updated, determine the front-end service information that matches the target configuration file.
[0056] In some embodiments, the execution entity may, in response to determining that the file status indicates the target configuration file has been updated, determine front-end service information matching the target configuration file. This front-end service information may be information corresponding to functions included in the front-end application. For example, the front-end service information may include: a front-end service identifier and a set of server address information for deploying the front-end service.
[0057] As an example, the aforementioned execution entity can use SQL (Structured Query Language) statements to query the target database to determine the front-end service information that matches the target configuration file.
[0058] Step 203: According to the synchronization type corresponding to the target configuration file, synchronize the target configuration file to at least one first target server corresponding to the front-end service information, so that at least one first target server can perform hot file updates according to the target configuration file.
[0059] In some embodiments, the execution entity may synchronize the target configuration file to at least one first target server corresponding to the front-end service information according to the synchronization type corresponding to the target configuration file, so that the at least one first target server performs hot file updates according to the target configuration file.
[0060] The aforementioned synchronization type can characterize the synchronization method for synchronizing the target configuration file to at least one first target server. The at least one first target server can be a server that deploys the front-end service corresponding to the aforementioned front-end service information. For example, the target database can also store the synchronization type of the target configuration file. The executing entity can sequentially determine the synchronization type of the target configuration file using SQL statements. For example, the synchronization type can be "asynchronous synchronization." "Asynchronous synchronization" can characterize synchronizing the target configuration file to at least one first target server using asynchronous communication. Alternatively, the executing entity can determine the at least one target server based on the set of server address information for deploying the front-end service contained in the front-end service information. The front-end service can be a service provided to the user through a front-end page. For example, the front-end service can be a "login service." Another example is an "information display service." The "login service" can be used for account login. The "information display service" can be a service for displaying information such as item information. The front-end service can be characterized by corresponding functional functions. For example, if the front-end service is a "login service," then the corresponding functional function can be a function for user login.
[0061] As an example, at least one of the target servers mentioned above can implement hot file updates of the target configuration file through hook functions. For instance, when a user calls function A in the front-end application corresponding to the front-end service information, the target server can call the configuration item in the target configuration file that matches function A through the hook function, thereby achieving hot file updates.
[0062] The above embodiments of this disclosure have the following beneficial effects: the file synchronization method of some embodiments of this disclosure improves the synchronization efficiency of configuration files, ensuring the normal operation and use of front-end applications. Specifically, the reason for the extremely low synchronization efficiency of configuration files corresponding to front-end applications is that different front-end applications often have different development models, so configuration files need to be updated and synchronized separately for front-end applications with different architectures, which leads to extremely low synchronization efficiency. Based on this, some embodiments of this disclosure first determine the file status of the target configuration file. Then, in response to determining that the file status indicates that the target configuration file has been updated, front-end service information matching the target configuration file is determined. Since when the configuration file is updated, the corresponding front-end services often need to be updated in a timely manner to ensure that the front-end services can be used normally, this disclosure determines the front-end service information matching the target configuration file when the target configuration file changes, thereby determining which front-end services need to be updated. Finally, according to the synchronization type corresponding to the target configuration file, the target configuration file is synchronized to at least one first target server corresponding to the front-end service information, so that the at least one first target server performs hot file updates according to the target configuration file. When dealing with a large user base, it's often necessary to deploy the front-end service across multiple servers to handle the surge in user access. Therefore, the target configuration file needs to be synchronized to all servers corresponding to the front-end service information. Furthermore, considering that cold updates (i.e., closing the server to load the configuration file) can lead to the loss of cached data and requested data, hot updates are adopted. This ensures that configuration files are replaced and updated while the system continues to operate normally. This approach abstracts the configuration file update requirements of front-end applications with different architectures, enabling automated configuration file synchronization and significantly improving synchronization efficiency.
[0063] Further reference Figure 3 This illustrates a flow 300 of another embodiment of the file synchronization method. Flow 300 of the file synchronization method includes the following steps:
[0064] Step 301: Determine the file status of the target configuration file.
[0065] Step 302: In response to determining that the file status indicates the target configuration file has been updated, determine the front-end service information that matches the target configuration file.
[0066] In some embodiments, the specific implementation of steps 301-302 and the resulting technical effects can be found in [reference needed]. Figure 2 Steps 201-202 in the corresponding embodiments will not be repeated here.
[0067] Step 303: In response to determining that the synchronization type is the first synchronization type, determine the synchronization method of the target configuration file.
[0068] In some embodiments, the executing entity may determine the synchronization method of the target configuration file in response to determining that the synchronization type is the first synchronization type. The synchronization method may characterize the synchronization path of the target configuration file. The first synchronization type may characterize passive push, i.e., non-spontaneous push. The executing entity may determine the synchronization method of the target configuration file by querying the target database.
[0069] Step 304: According to the synchronization method, synchronize the target configuration file to at least one first target server corresponding to the front-end service information.
[0070] In some embodiments, the execution entity may synchronize the target configuration file to at least one first target server corresponding to the front-end service information according to the above synchronization method.
[0071] As an example, the above synchronization method represents synchronizing the target configuration file to at least one first target server by creating a simplex file transfer channel. For instance, the execution entity can synchronize the target configuration file to at least one first target server via SSE (Server-SentEvents).
[0072] In some optional implementations of certain embodiments, the execution entity may synchronize the target configuration file to at least one first target server corresponding to the front-end service information according to a synchronization method. Specifically, in response to determining that the synchronization method is a first synchronization method, the execution entity may, for each of the at least one first target server, synchronize the target configuration file to a target directory contained in the first target server using a synchronization command. The first synchronization method may represent using a synchronization command to synchronize the target configuration file to the first target server. The synchronization may be a command used for file synchronization. For example, the synchronization command may be the rsync command under the Linux operating system.
[0073] In some optional implementations of certain embodiments, the process by which the execution entity synchronizes the target configuration file to at least one first target server corresponding to the front-end service information according to the synchronization method may include the following steps:
[0074] The first step is to create a file stream push pipeline in response to determining that the above synchronization method is the second synchronization method.
[0075] The second synchronization method mentioned above can be characterized by file streaming through a file streaming pipeline.
[0076] As an example, the file stream push pipeline described above can be a data structure used for file push. For instance, the execution entity described above can implement the file stream push pipeline using the pipe() function in Node.js.
[0077] The second step is to push the target configuration file to at least one first target server corresponding to the aforementioned front-end service information through the file stream push pipeline.
[0078] Step 305: In response to determining that the synchronization type is the second synchronization type, the target configuration file is added to the configuration file pool.
[0079] In some embodiments, the execution entity may add the target configuration file to the configuration file pool in response to determining that the synchronization type is the second synchronization type. The second synchronization type may represent active file synchronization. The configuration file pool may be a storage structure for storing configuration files that need to be updated.
[0080] Step 306: In response to the determination that a configuration file exists in the configuration file pool, start the configuration file pool.
[0081] In some embodiments, the execution entity may start the configuration file pool in response to determining that a configuration file exists in the configuration file pool.
[0082] As an example, the aforementioned execution entity can read the storage space corresponding to the aforementioned configuration file pool. When the read data is not empty, it can be determined that there is a configuration file in the aforementioned configuration file pool.
[0083] As another example, the aforementioned execution entity can determine whether a configuration file exists in the configuration file pool by checking if the thread corresponding to the configuration file pool is occupied. If the thread corresponding to the configuration file pool is occupied, it can be concluded that a configuration file exists in the configuration file pool.
[0084] Step 307: In response to confirming that the configuration file pool has started successfully, push the target configuration file stored in the configuration file pool to at least one first target server corresponding to the front-end service information.
[0085] In some embodiments, the execution entity may, in response to determining that the configuration file pool has started successfully, push the target configuration file stored in the configuration file pool to at least one first target server corresponding to the front-end service information.
[0086] As an example, the aforementioned execution entity can push the target configuration file stored in the configuration file pool to at least one first target server corresponding to the front-end service information via the HTTP / HTTPS protocol.
[0087] As another example, the aforementioned execution entity can use the WebSocket protocol to push the target configuration file stored in the configuration file pool to at least one first target server corresponding to the front-end service information.
[0088] Optionally, the aforementioned execution entity may also periodically scan the aforementioned configuration file pool, and when the aforementioned target configuration file is detected, push the aforementioned target configuration file to at least one first target server corresponding to the front-end service information.
[0089] and Figure 2 Compared with some corresponding embodiments, this disclosure refines and improves the synchronization method of the target configuration file, so that the appropriate synchronization method can be flexibly selected according to the synchronization needs of different front-end applications, which greatly improves the synchronization efficiency of the target configuration file.
[0090] Figure 4 This is a schematic diagram illustrating an application scenario of a file update method according to some embodiments of this disclosure.
[0091] exist Figure 4 In the application scenario, firstly, the computing device 401 can obtain the target configuration file 102, wherein the target configuration file 102 adopts the following... Figure 2 to Figure 3 The method described above generates the configuration file 402; finally, the computing device 401 can perform a hot update of the configuration file 402 to be updated based on the target configuration file 102 described above.
[0092] It should be noted that the aforementioned computing device 401 can be either hardware or software. When the computing device is hardware, it can be implemented as a distributed cluster consisting of multiple servers or terminal devices, or as a single server or a single terminal device. When the computing device is software, it can be installed within the hardware devices listed above. It can be implemented as, for example, multiple software programs or software modules used to provide distributed services, or as a single software program or software module. No specific limitations are made here.
[0093] It should be understood that Figure 4 The number of computing devices shown is merely illustrative. Any number of computing devices can be used depending on implementation needs.
[0094] Further reference Figure 5 The document illustrates a flow 500 of another embodiment of the file update method. Flow 500 of the file update method includes the following steps:
[0095] Step 501: Obtain the target configuration file.
[0096] In some embodiments, the execution body of the file update method (e.g. Figure 4 The computing device 401 shown can be... Figure 1 At least one of the first target servers 106 shown can obtain the target configuration file via a wired or wireless connection. The target configuration file can be a configuration file used for hot-updating a configuration file to be updated. The configuration file to be updated can be a configuration file of the front-end application that needs to be updated, stored on the first target server. The target configuration file can be configured as follows: Figure 2 to Figure 3 The method shown is used to generate it.
[0097] Step 502: Perform a hot update of the configuration file to be updated based on the target configuration file.
[0098] In some embodiments, the execution entity may perform a hot update of the configuration file to be updated based on the target configuration file.
[0099] As an example, the aforementioned execution entity can create a listening thread to monitor whether the target configuration file has been received. Upon detecting that the target configuration file has been received, it is loaded into the cache. Simultaneously, functions of the front-end application that use the configuration items contained in the configuration file to be updated are redirected to the location of the target configuration file in the cache. This ensures that when a function of the front-end application using the configuration items contained in the configuration file to be updated is invoked, the configuration item associated with the function in the target configuration file will be directly called, thereby achieving hot reloading of the configuration file to be updated.
[0100] This method enables hot updates of configuration files, avoiding the server restart issue associated with cold updates. This is especially important when the front-end application is deployed across multiple servers, as excessively long restart times can negatively impact user experience. Furthermore, it avoids the potential loss of cached data and received user requests that might occur during server restarts.
[0101] Further reference Figure 6 The document illustrates a flow 600 of another embodiment of the file update method. Flow 600 of the file update method includes the following steps:
[0102] Step 601: In response to the existence of a configuration file to be updated, obtain the target configuration file corresponding to the configuration file to be updated.
[0103] In some embodiments, the execution body of the file update method (e.g. Figure 4The computing device 401 shown can be... Figure 1 At least one of the first target servers 106 shown can, in response to the existence of the aforementioned configuration file to be updated, obtain the target configuration file corresponding to the configuration file to be updated. The configuration file to be updated is a configuration file of the front-end application that needs to be updated, stored on the aforementioned first target server. The target configuration file can be a configuration file used to update the aforementioned configuration file to be updated.
[0104] As an example, firstly, the aforementioned executing entity can generate a unique identifier corresponding to the configuration file to be updated. For instance, this unique identifier could be a digital signature of the configuration file. The executing entity can use the MD5 (Message-Digest) algorithm to digitally sign the configuration file to generate the unique identifier. Then, the executing entity can periodically send this unique identifier to a second target server (e.g., Figure 1 The computing device 101 shown is used to compare the configuration file with the unique identifier of the configuration file corresponding to the configuration file to be updated stored on the second target server. If the two identifiers match, it is determined that there is no configuration file to be updated. If the two identifiers do not match, it is determined that there is a configuration file to be updated.
[0105] Alternatively, the above-mentioned configuration file to be updated can be generated through the following steps:
[0106] The first step is to scan the configuration files stored locally to obtain at least one candidate configuration file.
[0107] The configuration file stored locally can be the configuration file stored on the first target server. For example, the aforementioned execution entity can recursively use the `find` command under the Linux operating system to scan for configuration files in local storage.
[0108] The second step is to determine, in response to the determination that there is a candidate configuration file with changed data among at least one of the above candidate configuration files, to identify the candidate configuration file with changed data as the above configuration file to be updated.
[0109] As an example, the aforementioned execution entity can determine whether any candidate configuration file among the at least one candidate configuration file has undergone data changes by executing a monitoring script. The monitoring script can be a script containing the inotifywait command from the inotify-tools component package. The inotifywait command can be a command used to monitor whether files have changed.
[0110] In some optional implementations of certain embodiments, the process of the execution entity obtaining the target configuration file may include the following steps:
[0111] The first step is to create a file stream pull pipeline.
[0112] The aforementioned file stream retrieval pipeline can be a data structure used to retrieve the target configuration file from a second target server (such as computing device 101).
[0113] As an example, the aforementioned execution entity can implement the file stream pulling pipeline using the stream.pipe() function in Node.js.
[0114] The second step is to pull the target configuration file from the second target server according to the file stream pull pipeline described above.
[0115] Step 602: Determine the file path of the configuration file to be updated.
[0116] In some embodiments, the executing entity can determine the file path of the configuration file to be updated. For example, the file path can be the absolute path of the configuration file to be updated on the first target server. The executing entity can determine the file path by scanning the location of the scanned configuration file to be updated. For example, the file path can be "D:\Configuration file to be updated", where "D:\Configuration file to be updated" indicates that the configuration file to be updated is in the root directory of drive D.
[0117] Step 603: Determine the cache area corresponding to the configuration file to be updated based on the file path.
[0118] In some embodiments, the execution entity can determine the cache area corresponding to the configuration file to be updated based on the file path described above.
[0119] As an example, the aforementioned execution entity can determine the cache area where the configuration file to be updated is located in the cache based on the above file path and cache mapping relationship.
[0120] Step 604: Clear the data stored in the cache.
[0121] In some embodiments, the executing entity can clear the data stored in the cache. For example, the executing entity can release the cache to clear the data stored in it. Alternatively, the executing entity can first mark the location of the cache within the cache, and then clear the data in the cache. Afterward, the executing entity can reclaim the storage space where the cache resides in the cache. This method avoids the possibility that releasing the cache might lead to it being occupied by other programs.
[0122] Step 605: In response to determining that the buffer has been cleared, the target configuration file is loaded into the cache.
[0123] In some embodiments, the execution entity may load the target configuration file into the cache area in response to determining that the buffer has been cleared.
[0124] Optionally, the aforementioned executing entity can push the data from the target configuration file stored in the cache to the page service function in the front-end application corresponding to the target configuration file, so that the page service function can use the data corresponding to the target configuration file. The page service function can be a function provided to the user through the front-end page, such as a "login service" function, an "information browsing service" function, or a "video playback service" function.
[0125] Since data often needs to be loaded into the cache when it is accessed, especially frequently accessed configuration files, hot updates of configuration files can be achieved by replacing the configuration files to be updated stored in the cache with the target configuration file.
[0126] Further reference Figure 7 As an implementation of the methods shown in the above figures, this disclosure provides some embodiments of a file synchronization device, which are similar to... Figure 2 Corresponding to the method embodiments shown, the device can be specifically applied to various electronic devices.
[0127] like Figure 7 As shown, a file synchronization device 700 in some embodiments includes: a first determining unit 701, a second determining unit 702, and a synchronization unit 703. The first determining unit 701 is configured to determine the file status of a target configuration file; the second determining unit 702 is configured to, in response to determining that the file status indicates the target configuration file has been updated, determine front-end service information matching the target configuration file; the synchronization unit 703 is configured to, according to the synchronization type corresponding to the target configuration file, synchronize the target configuration file to at least one first target server corresponding to the front-end service information, so that the at least one first target server performs a hot file update based on the target configuration file.
[0128] Optionally, the above synchronization unit is further configured to: in response to determining that the above synchronization type is a first synchronization type, determine the synchronization method of the above target configuration file; and synchronize the above target configuration file to at least one first target server corresponding to the above front-end service information according to the above synchronization method.
[0129] In some optional implementations of some embodiments, the synchronization unit 703 is further configured to: in response to determining that the synchronization method is a first synchronization method, for each of the at least one first target server, synchronize the target configuration file to the target directory contained in the first target server by means of a synchronization command.
[0130] In some optional implementations of some embodiments, the synchronization unit 703 is further configured to: create a file stream push pipeline in response to determining that the synchronization method is a second synchronization method; and push the target configuration file to at least one first target server corresponding to the front-end service information through the file stream push pipeline.
[0131] In some optional implementations of some embodiments, the synchronization unit 703 is further configured to: add the target configuration file to the configuration file pool in response to determining that the synchronization type is a second synchronization type; start the configuration file pool in response to determining that a configuration file exists in the configuration file pool; and push the target configuration file stored in the configuration file pool to at least one first target server corresponding to the front-end service information in response to determining that the configuration file pool has started successfully.
[0132] It is understandable that the units described in the device 700 are related to the reference. Figure 2 The steps in the described method correspond to each other. Therefore, the operations, features, and beneficial effects described above for the method also apply to the device 700 and the units contained therein, and will not be repeated here.
[0133] Further reference Figure 8 As an implementation of the methods shown in the above figures, this disclosure provides some embodiments of a file updating apparatus, which are similar to... Figure 4 Corresponding to the method embodiments shown, the device can be specifically applied to various electronic devices.
[0134] like Figure 8 As shown, a file update apparatus 800 in some embodiments includes an acquisition unit 801 and a hot update unit 802. The acquisition unit 801 is configured to acquire a target configuration file, wherein the target configuration file adopts... Figure 2 to Figure 3 The method shown generates a hot update unit 802, which is configured to perform a hot update of the configuration file to be updated based on the target configuration file described above.
[0135] In some optional implementations of some embodiments, the acquisition unit 801 is further configured to: in response to the existence of a configuration file to be updated, acquire the target configuration file corresponding to the configuration file to be updated.
[0136] In some optional implementations of some embodiments, the above-mentioned configuration file to be updated is generated by the following steps: scanning the configuration files stored locally to obtain at least one candidate configuration file; in response to determining that there is a candidate configuration file with changed data among the at least one candidate configuration file, the candidate configuration file with changed data is determined as the above-mentioned configuration file to be updated.
[0137] In some optional implementations of some embodiments, the acquisition unit 801 is further configured to: create a file stream pull pipeline; and pull the target configuration file from the second target server according to the file stream pull pipeline.
[0138] In some optional implementations of some embodiments, the hot update unit 802 is further configured to: determine the file path of the configuration file to be updated; determine the cache area corresponding to the configuration file to be updated based on the file path; clear the data stored in the cache area; and, in response to determining that the cache area has been cleared, load the target configuration file into the cache area.
[0139] It is understandable that the units described in the device 800 are related to the reference. Figure 4 The steps in the described method correspond to each other. Therefore, the operations, features, and beneficial effects described above for the method also apply to the device 800 and the units contained therein, and will not be repeated here.
[0140] The following is for reference. Figure 9 It illustrates electronic devices suitable for implementing some embodiments of the present disclosure (such as...). Figure 1 The diagram shows the structure of the computing device 101)900. Figure 9 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of this disclosure.
[0141] like Figure 9 As shown, the electronic device 900 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage device 908 into a random access memory (RAM) 903. The RAM 903 also stores various programs and data required for the operation of the electronic device 900. The processing unit 901, ROM 902, and RAM 903 are interconnected via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0142] Typically, the following devices can be connected to I / O interface 905: input devices 906 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 907 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 908 including, for example, magnetic tapes, hard disks, etc.; and communication devices 909. Communication device 909 allows electronic device 900 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 9 An electronic device 900 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively. Figure 9 Each box shown can represent a device or multiple devices as needed.
[0143] In particular, according to some embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, some embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 909, or installed from a storage device 908, or installed from a ROM 902. When the computer program is executed by the processing device 901, it performs the functions defined in the methods of some embodiments of this disclosure.
[0144] It should be noted that, in some embodiments of this disclosure, the computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In some embodiments of this disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In some embodiments of this disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0145] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0146] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device. The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: determine the file status of a target configuration file; in response to determining that the file status indicates the target configuration file has been updated, determine front-end service information matching the target configuration file; and, according to the synchronization type corresponding to the target configuration file, synchronize the target configuration file to at least one first target server corresponding to the front-end service information, so that the at least one first target server performs a hot file update based on the target configuration file.
[0147] Computer program code for performing operations of some embodiments of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0148] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0149] The units described in some embodiments of this disclosure can be implemented in software or hardware. The described units can also be housed in a processor; for example, a processor may be described as including a first determining unit, a second determining unit, and a synchronization unit. The names of these units do not necessarily limit the specific unit; for example, the first determining unit may also be described as "a unit for determining the file status of a target configuration file."
[0150] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0151] The above description is merely a selection of preferred embodiments of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in the embodiments of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described inventive concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features with similar functions disclosed in the embodiments of this disclosure.
Claims
1. A file synchronization method, comprising: Determine the file status of the target configuration file, which is the configuration file corresponding to the front-end application and is used to ensure the normal operation of the front-end application; In response to determining that the file status indicates that the target configuration file has been updated, front-end service information matching the target configuration file is determined, wherein the front-end service information is information corresponding to the functions included in the front-end application; According to the synchronization type corresponding to the target configuration file, the target configuration file is synchronized to at least one first target server corresponding to the front-end service information, so that the at least one first target server can perform hot file updates according to the target configuration file. The at least one first target server is a server that deploys the front-end service corresponding to the front-end service information. The synchronization type includes a first synchronization type and a second synchronization type.
2. The method according to claim 1, wherein, The step of synchronizing the target configuration file to at least one first target server corresponding to the front-end service information according to the synchronization type corresponding to the target configuration file includes: In response to determining that the synchronization type is the first synchronization type, the synchronization method of the target configuration file is determined; According to the synchronization method, the target configuration file is synchronized to at least one first target server corresponding to the front-end service information.
3. The method according to claim 2, wherein, The step of synchronizing the target configuration file to at least one first target server corresponding to the front-end service information according to the synchronization method includes: In response to determining that the synchronization method is the first synchronization method, for each of the at least one first target server, the target configuration file is synchronized to the target directory contained in the first target server by means of a synchronization command.
4. The method according to claim 2, wherein, The step of synchronizing the target configuration file to at least one first target server corresponding to the front-end service information according to the synchronization method includes: In response to determining that the synchronization method is the second synchronization method, a file stream push pipeline is created; The target configuration file is pushed to at least one first target server corresponding to the front-end service information through the file stream push pipeline.
5. The method according to claim 1, wherein, The step of synchronizing the target configuration file to at least one first target server corresponding to the front-end service information according to the synchronization type corresponding to the target configuration file includes: In response to determining that the synchronization type is the second synchronization type, the target configuration file is added to the configuration file pool; In response to determining that a configuration file exists in the configuration file pool, the configuration file pool is started; In response to the successful startup of the configuration file pool, the target configuration file stored in the configuration file pool is pushed to at least one first target server corresponding to the front-end service information.
6. A file update method, comprising: Obtain the target configuration file, wherein the target configuration file is synchronously obtained by the method described in any one of claims 1-5; Based on the target configuration file, perform a hot update of the configuration file to be updated.
7. The method according to claim 6, wherein, The process of obtaining the target configuration file includes: In response to the existence of a configuration file to be updated, the target configuration file corresponding to the configuration file to be updated is obtained.
8. The method according to claim 6, wherein, The configuration file to be updated is generated through the following steps: Scan the configuration files stored locally to obtain at least one candidate configuration file; In response to determining that there is a candidate configuration file among the at least one candidate configuration file whose data has changed, the candidate configuration file whose data has changed is determined as the configuration file to be updated.
9. The method according to claim 6, wherein, The process of obtaining the target configuration file includes: Create a file stream pull pipeline; The target configuration file is pulled from the second target server according to the file stream pull pipeline.
10. The method according to claim 9, wherein, The step of performing a hot file update on the configuration file to be updated based on the target configuration file includes: Determine the file path of the configuration file to be updated; Determine the cache area corresponding to the configuration file to be updated based on the file path; Clear the data stored in the cache area; In response to determining that the cache area has been cleared, the target configuration file is loaded into the cache area.
11. A file synchronization device, comprising: The first determining unit is configured to determine the file status of the target configuration file, which is the configuration file corresponding to the front-end application and is used to ensure the normal operation of the front-end application. The second determining unit is configured to, in response to determining that the file status indicates that the target configuration file has been updated, determine front-end service information matching the target configuration file, wherein the front-end service information is information corresponding to the functions included in the front-end application; The synchronization unit is configured to synchronize the target configuration file to at least one first target server corresponding to the front-end service information according to the synchronization type corresponding to the target configuration file, so that the at least one first target server performs hot file updates according to the target configuration file, wherein the at least one first target server is a server that deploys the front-end service corresponding to the front-end service information, and the synchronization type includes a first synchronization type and a second synchronization type.
12. A file updating device, comprising: The acquisition unit is configured to acquire a target configuration file, wherein the target configuration file is obtained synchronously by the method described in any one of claims 1-5; The hot update unit is configured to perform a hot update of the configuration file to be updated based on the target configuration file.
13. An electronic device, comprising: One or more processors; A storage device on which one or more programs are stored; When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1 to 10.
14. A computer-readable medium having a computer program stored thereon, wherein, When the program is executed by the processor, it implements the method as described in any one of claims 1 to 10.
Citation Information
Patent Citations
Method and system for automatically synchronously updating file name in Content Delivery Network (CDN)
CN107370791A
Configuration updating method and device, server and readable storage medium
CN111064626A