Disclosure of Invention
In view of this, the present invention provides a configuration file pushing method, a server and a storage medium, which can improve the update efficiency of the new version application program and the experience effect of the user.
Firstly, in order to achieve the above objective, the present invention provides a method for pushing a configuration file, which includes the following steps:
s1, separating an application program from a corresponding configuration file thereof, and storing the configuration file in a database of a configuration center of the application program;
s2, acquiring configuration files of the application program from the database at intervals of a first preset time according to a predetermined acquisition rule, and backing up the acquired configuration files in a local disk of a server running the configuration center;
s3, after receiving a request for acquiring the configuration file of the application program sent by the client, judging whether the database runs normally or not;
and S4, if the database runs normally, acquiring the configuration file of the application program from the database and sending the configuration file to the client, and if the database is down, acquiring the configuration file of the application program from a local disk of the server and sending the configuration file to the client.
Further, the predetermined acquisition rule includes:
judging whether the configuration file of the updated version of the application program exists in the database or not every first preset time, if so, acquiring the configuration file of the updated version, and if not, acquiring the configuration file of the existing version.
Further, the predetermined acquisition rule includes:
judging whether the configuration file of the updated version of the application program exists in the database or not every first preset time, if so, acquiring the configuration file of the updated version, and if not, acquiring the configuration file of the existing version.
Further, the step S2 further includes the following steps:
and synchronously sending the acquired configuration files to local cache files of all clients running the application program.
Further, in the step S3, the determining whether the database operates normally includes:
if the data is written into or read from the database successfully within the second preset time, the database is determined to run normally, and if the data is written into or read from the database within the second preset time, the database is determined to be down.
Further, in the step S4, the obtaining the new version of the configuration file from the local disk of the server and sending the new version of the configuration file to the client further includes:
if the new version of the configuration file is failed to be obtained from the local disk of the server within the third preset time, sending the server downtime information to the client, and prompting the user to obtain the corresponding configuration file from the local disk of the client.
In addition, in order to achieve the above object, the present invention also provides a server, the server including a memory, and a processor, the memory storing a profile pushing program, the profile pushing program implementing the following steps when executed by the processor:
a1, separating an application program from a corresponding configuration file thereof, and storing the configuration file in a database of a configuration center of the application program;
a2, acquiring configuration files of the application program from the database at intervals of a first preset time according to a predetermined acquisition rule, and backing up the acquired configuration files in a local disk of a server running the configuration center;
a3, after receiving a request for acquiring the configuration file of the application program sent by the client, judging whether the database runs normally or not;
and A4, if the database runs normally, acquiring the configuration file of the application program from the database and sending the configuration file to the client, and if the database is down, acquiring the configuration file of the application program from a local disk of the server and sending the configuration file to the client.
Further, the predetermined acquisition rule includes:
judging whether the configuration file of the updated version of the application program exists in the database or not every first preset time, if so, acquiring the configuration file of the updated version, and if not, acquiring the configuration file of the existing version.
Further, the step A2 further includes the following steps:
and synchronously sending the acquired configuration files to local cache files of all clients running the application program.
Further, in the step S3, the determining whether the database operates normally includes:
if the data is written into or read from the database successfully within the second preset time, the database is determined to run normally, and if the data is written into or read from the database within the second preset time, the database is determined to be down.
Further, to achieve the above object, the present invention also provides a computer-readable storage medium storing a profile pushing program executable by at least one processor to cause the at least one processor to perform the steps of the profile pushing method as described above.
Compared with the prior art, the configuration file pushing method, the server and the computer readable storage medium provided by the invention have the advantages that the application program is separated from the corresponding configuration file, the configuration file is stored in the database of the configuration center of the application program, the configuration file of the application program is acquired from the database every a first preset time, the acquired configuration file is backed up in the local disk of the server running the configuration center, and the acquired configuration file is synchronously transmitted to the local cache file of each client running the application program; after receiving a request for acquiring the configuration file of the application program sent by a client, judging whether the database runs normally or not; and if the database is down, acquiring the configuration file of the application program from a local disk of the server and pushing the configuration file to the client. The updating efficiency of the new version application program and the experience effect of the user are improved.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be noted that the description of "first", "second", etc. in this disclosure is for descriptive purposes only and is not to be construed as indicating or implying a relative importance or implying an indication of the number of technical features being indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In addition, the technical solutions of the embodiments may be combined with each other, but it is necessary to base that the technical solutions can be realized by those skilled in the art, and when the technical solutions are contradictory or cannot be realized, the combination of the technical solutions should be considered to be absent and not within the scope of protection claimed in the present invention.
Referring to fig. 1, a schematic diagram of an alternative hardware architecture of a server 1 according to the present invention is shown. In the present embodiment, the server 1 may include, but is not limited to, amemory 11, aprocessor 12, and anetwork interface 13, which may be communicatively connected to each other through asystem bus 14. It is noted that fig. 1 only shows a server 1 with components 11-14, but it is understood that not all of the illustrated components are required to be implemented, and that more or fewer components may alternatively be implemented.
Thememory 11 includes at least one type of readable storage medium including flash memory, hard disk, multimedia card, card memory (e.g., SD or DX memory, etc.), random Access Memory (RAM), static Random Access Memory (SRAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), programmable Read Only Memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, thememory 11 may be an internal storage unit of the server 1, such as a hard disk or a memory of the server 1. In other embodiments, thememory 11 may also be an external storage device of the server 1, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash Card (Flash Card) or the like, which are provided on the server 1. Of course, thememory 11 may also comprise both the internal storage unit of the server 1 and its external storage device. In this embodiment, thememory 11 is generally used to store an operating system and various application software installed on the server 1, such as a configuration file pushing program. Further, thememory 11 may be used to temporarily store various types of data that have been output or are to be output.
Processor 12 may be a central processing unit (Central Processing Unit, CPU), controller, microcontroller, microprocessor, or other data processing chip in some embodiments. Theprocessor 12 is typically used to control the overall operation of the server 1. In this embodiment, theprocessor 12 is configured to execute program codes stored in thememory 11 or process data, for example, execute a profile pushing program stored in thememory 11.
Thenetwork interface 13 may comprise a wireless network interface or a wired network interface, thenetwork interface 13 typically being used to establish a communication connection between the server 1 and other electronic devices.
Thesystem bus 14 is used to implement the communication connections between these components.
Fig. 2 only shows a server with components 11-14 and a profile pushing program supporting a greyscale mode, but it should be understood that not all shown components need to be implemented, and that more or fewer components may alternatively be implemented.
Optionally, the server 1 may further comprise a user interface, which may comprise a Display (Display), an input unit such as a Keyboard (Keyboard), and optionally a standard wired interface, a wireless interface.
Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch, or the like. The display may also be referred to as a display screen or a display unit, as appropriate, for displaying information processed in the social network-based user keyword extraction means and for displaying a visualized user interface.
Further, in one embodiment of the server 1 shown in fig. 1, the configuration file pushing program stored in thememory 11 is executed by theprocessor 12 to implement the following steps:
A. separating an application program from a corresponding configuration file thereof, and storing the configuration file in a database of a configuration center of the application program;
in this embodiment, an application program is separated from a configuration file corresponding to the application program, and the configuration file corresponding to the application program is stored in a database of a configuration center of the application program, when each application program has a new version, the configuration file corresponding to the new version is stored in the database of the configuration center, and each version of configuration file contains configuration information of a corresponding running environment, when the application program is released to each client running in different environments, each client in different environments needs to initiate a request for acquiring the corresponding configuration file to the configuration center.
In this embodiment, the configuration center includes an API end and a WEB end based on a master database and a slave database, where the WEB end and the API end both adopt a multi-node deployment mode, and each user may trigger an access instruction for accessing a database corresponding to a database website through the WEB end of the database by inputting an address of the database to be accessed in a browser address bar of each corresponding client.
B. Acquiring configuration files of the application program from the database at intervals of a first preset time according to a predetermined acquisition rule, and backing up the acquired configuration files in a local disk of a server running the configuration center;
in this embodiment, the configuration file pushing program stored in thememory 11 in the server 1 detects whether there is an updated version of configuration file in the database at intervals of a first preset time (for example, at intervals of 30 seconds), and after detecting that there is an updated version of configuration file, backs up the updated version of configuration file as the latest version of configuration file in the local disk of the server 1, or after not detecting the updated version of configuration file, acquires the existing version of configuration file and backs up the updated version of configuration file in the local disk of the server 1.
Further, in another embodiment, after detecting that the configuration file of the updated version is detected, the detected configuration file of the updated version is synchronously sent to the local cache file of each client running the application program, or after detecting that the configuration file of the updated version is not detected, the configuration file of the existing version is obtained and synchronously sent to the local cache file of each client running the application program.
C. After receiving a request for acquiring the configuration file of the application program sent by a client, judging whether the database runs normally or not;
in this embodiment, when a user needs to update the application program installed in a client (mobile terminal), or when the client installs and runs the application program, the server address of a configuration center corresponding to the running application program may be input into a browser address field of the client, so as to trigger an access instruction of a server corresponding to the running application program, and send a request for obtaining a configuration file corresponding to the application program to the server, and after receiving the request for obtaining the configuration file of the application program sent by the client, the server determines whether a database storing the configuration file of the application program is running normally.
Typically, the reasons for database downtime include that if the number of threads simultaneously requesting connection exceeds the maximum number of threads currently available in parallel in the thread pool, a downtime state may occur in the database when a thread is blocked or stopped, or when the database is connected by the driverManager or the data source, a subsequent process may be affected in an exception handling when the database is not connected, which may possibly result in data downtime.
In a specific implementation manner, determining whether the database operates normally includes: if the data is successfully written into or read from the database within a second preset time (for example, within 3 minutes), the database is determined to run normally, and if the data is not successfully written into or read from the database within the second preset time, the database is determined to be down.
D. And if the database is in normal operation, acquiring the configuration file of the application program from the database and sending the configuration file to the client, and if the database is down, acquiring the configuration file of the application program from a local disk of the server and sending the configuration file to the client.
Further, if the acquisition of the configuration file of the application program from the local disk of the server fails in the third preset time, sending the downtime information of the server to the client, and prompting the user to acquire the configuration file of the application program from the local disk of the client.
In general, a server may be caused by a system problem, a program application error, or insufficient machine configuration resources, and when the server is down, the server needs to be restarted, or the system security log of the server is checked to check the reason of the down, so that the corresponding configuration file cannot be obtained once the server is down.
According to the embodiment, the application program is separated from the corresponding configuration file, the configuration file is stored in the database of the configuration center of the application program, the configuration file of the application program is obtained from the database every first preset time, the obtained configuration file is backed up in a local disk of a server running the configuration center, and the obtained configuration file is synchronously sent to local cache files of all clients running the application program; after receiving a request for acquiring the configuration file of the application program sent by a client with identification information, judging whether the database runs normally or not; and if the database is in a down state, acquiring a corresponding configuration file from a local disk of the server and sending the corresponding configuration file to the client. The updating efficiency of the new version application program and the experience effect of the user are improved.
In addition, in other embodiments, the configuration file pushing program may be further divided into one or more program modules with different functions according to the functions implemented by the partial programs, where the one or more program modules are stored in thememory 11 and executed by one or more processors (in this embodiment, the processor 12), so as to implement the present invention.
For example, referring to fig. 2, a schematic program module of a profile pushing program in a preferred embodiment of the server of the present invention is shown. In this embodiment, the profile pushing program may be divided into aseparation module 201, abackup module 202, ajudgment module 203, and atransmission module 204. Wherein the program modules 201-204 perform functions or operational steps similar to those described above, and which are not described in detail herein, for example, wherein:
theseparation module 201 is configured to separate an application program from a configuration file corresponding to the application program, and store the configuration file in a database of a configuration center of the application program;
thebackup module 202 is configured to acquire a configuration file of the application program from the database at intervals of a first preset time according to a predetermined acquisition rule, and backup the acquired configuration file in a local disk of a server running the configuration center;
the judgingmodule 203 is configured to judge whether the database operates normally after receiving a request for acquiring a configuration file of the application program sent by the client;
the sendingmodule 204 is configured to obtain, if the database is running normally, a configuration file of the application program from the database and send the configuration file to the client, and if the database is down, obtain, from a local disk of the server, the configuration file of the application program and send the configuration file to the client.
In addition, the invention also provides a configuration file pushing method. Referring to fig. 3, a flowchart of a configuration file pushing method according to a preferred embodiment of the present invention is shown. The method may be performed by an apparatus, which may be implemented in software and/or hardware.
In this embodiment, the configuration file pushing method includes steps S301 to S304. Wherein,,
s301, separating an application program from a corresponding configuration file thereof, and storing the configuration file in a database of a configuration center of the application program;
in this embodiment, an application program is separated from a configuration file corresponding to the application program, and the configuration file corresponding to the application program is stored in a database of a configuration center of the application program, when each application program has a new version, the configuration file corresponding to the new version is stored in the database of the configuration center, and each version of configuration file contains configuration information of a corresponding running environment, when the application program is released to each client running in different environments, each client in different environments needs to initiate a request for acquiring the corresponding configuration file to the configuration center.
In this embodiment, the configuration center includes an API end and a WEB end based on a master database and a slave database, where the WEB end and the API end both adopt a multi-node deployment mode, and each user may trigger an access instruction for accessing a database corresponding to a database website through the WEB end of the database by inputting an address of the database to be accessed in a browser address bar of each corresponding client.
S302, acquiring configuration files of the application program from the database at intervals of a first preset time according to a predetermined acquisition rule, and backing up the acquired configuration files in a local disk of a server running the configuration center;
in this embodiment, the configuration file pushing program stored in thememory 11 in the server 1 detects whether there is an updated version of configuration file in the database at intervals of a first preset time (for example, at intervals of 30 seconds), and after detecting that there is an updated version of configuration file, backs up the updated version of configuration file as the latest version of configuration file in the local disk of the server 1, or after not detecting the updated version of configuration file, acquires the existing version of configuration file and backs up the updated version of configuration file in the local disk of the server 1.
Further, in another embodiment, after detecting that the configuration file of the updated version is detected, the detected configuration file of the updated version is synchronously sent to the local cache file of each client running the application program, or after detecting that the configuration file of the updated version is not detected, the configuration file of the existing version is obtained and synchronously sent to the local cache file of each client running the application program.
S303, after receiving a request for acquiring the configuration file of the application program sent by a client, judging whether the database runs normally or not;
in this embodiment, when a user needs to update the application program installed in a client (mobile terminal), or when the client installs and runs the application program, the server address of a configuration center corresponding to the running application program may be input into a browser address field of the client, so as to trigger an access instruction of a server corresponding to the running application program, and send a request for obtaining a configuration file corresponding to the application program to the server, and after receiving the request for obtaining the configuration file of the application program sent by the client, the server determines whether a database storing the configuration file of the application program is running normally.
Typically, the reasons for database downtime include that if the number of threads simultaneously requesting connection exceeds the maximum number of threads currently available in parallel in the thread pool, a downtime state may occur in the database when a thread is blocked or stopped, or when the database is connected by the driverManager or the data source, a subsequent process may be affected in an exception handling when the database is not connected, which may possibly result in data downtime.
In a specific implementation manner, determining whether the database operates normally includes: if the data is successfully written into or read from the database within a second preset time (for example, within 3 minutes), the database is determined to run normally, and if the data is not successfully written into or read from the database within the second preset time, the database is determined to be down.
And S304, if the database runs normally, acquiring the configuration file of the application program from the database and sending the configuration file to the client, and if the database is down, acquiring the configuration file of the application program from a local disk of the server and sending the configuration file to the client.
Further, if the acquisition of the configuration file of the application program from the local disk of the server fails in the third preset time, sending the downtime information of the server to the client, and prompting the user to acquire the configuration file of the application program from the local disk of the client.
In general, a server may be caused by a system problem, a program application error, or insufficient machine configuration resources, and when the server is down, the server needs to be restarted, or the system security log of the server is checked to check the reason of the down, so that the corresponding configuration file cannot be obtained once the server is down.
According to the embodiment, the application program is separated from the corresponding configuration file, the configuration file is stored in the database of the configuration center of the application program, the configuration file of the application program is obtained from the database every first preset time, the obtained configuration file is backed up in a local disk of a server running the configuration center, and the obtained configuration file is synchronously sent to local cache files of all clients running the application program; after receiving a request for acquiring the configuration file of the application program sent by a client with identification information, judging whether the database runs normally or not; and if the database is in a down state, acquiring the configuration file of the application program from a local disk of the server and sending the configuration file to the client. The updating efficiency of the new version application program and the experience effect of the user are improved.
Furthermore, the present invention also proposes a computer-readable storage medium storing a profile pushing program executable by at least one processor to cause the at least one processor to perform the steps of:
separating an application program from a corresponding configuration file thereof, and storing the configuration file in a database of a configuration center of the application program;
acquiring configuration files of the application program from the database at intervals of a first preset time according to a predetermined acquisition rule, and backing up the acquired configuration files in a local disk of a server running the configuration center;
after receiving a request for acquiring the configuration file of the application program sent by a client with identification information, judging whether the database runs normally or not;
and if the database is in normal operation, acquiring the configuration file of the application program from the database and sending the configuration file to the client, and if the database is down, acquiring the configuration file of the application program from a local disk of the server and sending the configuration file to the client.
The specific implementation process of the computer readable storage medium of the present invention is basically the same as that of the embodiments of the server and the configuration file pushing method, and is not described here.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) comprising instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the method according to the embodiments of the present invention.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the invention, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.