Summary of the invention
In view of the above problems, proposing the present invention can rapid configuration Application Instance to provide, and takies method and the device of a kind of Application Instance listening port of server-less resource.
Embodiments provide a kind of method of Application Instance listening port, the method comprises:
Primary application program reads configuration file;
According to the information of port each in configuration file and the path of storage subapplication startup file, be that each port starts corresponding subapplication example;
The each subapplication example started is adopted to monitor corresponding port.
Further, described method also comprises:
Primary application program, according to the subapplication example monitoring each port, records the corresponding relation of each port and its subapplication example in subapplication example list.
Further, described method also comprises:
Described primary application program monitors configuration file, judges whether configuration file changes;
When configuration file changes, operate accordingly according to the content after configuration file change.
Further, described when configuration file changes, carry out corresponding operation according to the content after configuration file change and comprise:
When there is newly-increased port in configuration file, primary application program starts new subapplication example and monitors described newly-increased port, and in subapplication example list, record the corresponding relation of this newly-increased port and the new described Application Instance started;
When the port in configuration file is deleted, primary application program is according to the corresponding relation recorded in subapplication example list, subapplication example corresponding for described deleted port is closed, and in subapplication example list, deletes the corresponding relation at this port place.
Further, described method also comprises:
Described primary application program is according to the time interval of setting, and according to each corresponding relation in described subapplication example list, whether the subapplication example detected in each corresponding relation breaks down;
When there is the Application Instance broken down, the port for this correspondence restarts subapplication example.
Embodiments provide a kind of device of Application Instance listening port, described device comprises:
Read module, for reading configuration file;
Starting module, for according to the information of port each in configuration file and the path of storage subapplication startup file, is that each port starts corresponding subapplication example;
Monitoring module, monitoring corresponding port for adopting each subapplication example of startup.
Further, described device also comprises:
Memory module, for according to the subapplication example monitoring each port, records the corresponding relation of each port and its subapplication example in subapplication example list.
Further, described device also comprises:
Detection module, for monitoring configuration file, judges whether configuration file changes; When configuration file changes, operate accordingly according to the content after configuration file change.
Further, described detection module, specifically for when there is newly-increased port in configuration file, primary application program starts new subapplication example and monitors described newly-increased port, and in subapplication example list, record the corresponding relation of this newly-increased port and the new described Application Instance started; When the port in configuration file is deleted, primary application program is according to the corresponding relation recorded in subapplication example list, subapplication example corresponding for described deleted port is closed, and in subapplication example list, deletes the corresponding relation at this port place.
Further, described device also comprises:
Restart module, for the time interval according to setting, according to each corresponding relation in described subapplication example list, whether the subapplication example detected in each corresponding relation breaks down; When there is the Application Instance broken down, the port for this correspondence restarts subapplication example.
Embodiments provide a kind of method and device of Application Instance listening port, in the method, primary application program is according to the information of port each in configuration file and the path storing subapplication startup file, for each port starts corresponding subapplication example, and each subapplication example started is adopted to monitor corresponding port.Due in embodiments of the present invention without the need to copying the physical file of subapplication example, decrease the operation to physical file, simple to operate, avoid the possibility producing mistake, and the installation file of subapplication in embodiments of the present invention only need deposit portion, saves storage space.
Above-mentioned explanation is only the general introduction of technical solution of the present invention, in order to technological means of the present invention can be better understood, and can be implemented according to the content of instructions, and can become apparent, below especially exemplified by the specific embodiment of the present invention to allow above and other objects of the present invention, feature and advantage.
Embodiment
In order to simplify the start-up course of Application Instance, saving storage space, embodiments providing a kind of method and device of Application Instance listening port.
Below with reference to accompanying drawings exemplary embodiment of the present disclosure is described in more detail.Although show exemplary embodiment of the present disclosure in accompanying drawing, however should be appreciated that can realize the disclosure in a variety of manners and not should limit by the embodiment set forth here.On the contrary, provide these embodiments to be in order to more thoroughly the disclosure can be understood, and complete for the scope of the present disclosure can be conveyed to those skilled in the art.
Below in conjunction with explanation accompanying drawing, the embodiment of the present invention is described.
The process of a kind of Application Instance listening port that Fig. 1 provides for the embodiment of the present invention, this process comprises the following steps:
S101: primary application program reads configuration file.
In embodiments of the present invention in order to each port can be monitored by promoter Application Instance, the information needing each port monitored is configured with in configuration file, the port numbers of concrete can be such as port, or the identification information of port, multiple port can being comprised in this configuration file, adding to needing the information of the port monitored in configuration file.In addition, in configuration file, also record the path of subapplication startup file, so as primary application program know can promoter application program from which path.
S102: according to the information of port each in configuration file and the path of storage subapplication startup file, be that each port starts corresponding subapplication example.
Concrete, primary application program is according to the startup path of the information of the port recorded in configuration file and subapplication startup file, for each interface enabling sub-Application Instance, after having started, port in subapplication example and configuration file is one to one, and namely each port is monitored by a sub-Application Instance.
S103: adopt each subapplication example started to monitor corresponding port.
Due in embodiments of the present invention without the need to copying the physical file of subapplication example, decrease the operation to physical file, simple to operate, avoid the possibility producing mistake, and the installation file of subapplication in embodiments of the present invention only need deposit portion, saves storage space.
In embodiments of the present invention in order to monitor the ruuning situation of subapplication example accurately, thus improve the stability of system, each port that primary application program is monitored according to each subapplication example, records the corresponding relation of each port of each subapplication example and monitoring thereof in subapplication example list.Concrete primary application program generates this subapplication example list in internal memory, records port and the corresponding relation to the subapplication example that it is monitored in this subapplication example list.For the ease of distinguishing each subapplication example, when starting each subapplication example, determine the mark of each subapplication example, wherein the mark of each subapplication example is unique, for this subapplication example of unique identification.
The content of configuration file can also be revised in embodiments of the present invention, such as the newly-increased information needing the port monitored in configuration file, or not need to monitor certain port, be about to the information deletion of a certain or certain the several port existed in configuration file before.In order to simplify the operation, realize the dynamic process that port adds and closes, described primary application program monitors configuration file in embodiments of the present invention, judges whether configuration file changes; When configuration file changes, operate accordingly according to the content after configuration file change.
Concrete, when primary application program listen to configuration file change time, carry out corresponding operation according to the content after configuration file change and comprise:
When there is newly-increased port in configuration file, primary application program starts new subapplication example and monitors described newly-increased port, and in subapplication example list, record the corresponding relation of this newly-increased port and the new described Application Instance started;
When the port in configuration file is deleted, primary application program is according to the corresponding relation recorded in subapplication example list, subapplication example corresponding for described deleted port is closed, and in subapplication example list, deletes the corresponding relation at this port place.
The process of a kind of Application Instance listening port that Fig. 2 provides for the embodiment of the present invention one, this process comprises the following steps:
S201: primary application program reads configuration file.
S202: according to the information of port each in configuration file and the path of storage subapplication startup file, be that each port starts corresponding subapplication example.
S203: adopt each subapplication example started to monitor corresponding port.
S204: each port that primary application program is monitored according to each subapplication example, records the corresponding relation of each port of each subapplication example and monitoring thereof in subapplication example list.
S205: primary application program monitors configuration file, judging whether configuration file changes, when judged result is for being, carrying out step S206, otherwise, carry out step S205.
S206: primary application program listens to configuration file when changing, operates accordingly according to the content after configuration file change.
Primary application program self preserves subapplication example list in embodiments of the present invention, in this subapplication list, preserve each port and monitor the corresponding relation of subapplication example of this port, when primary application program judges whether configuration file changes, according to each port recorded in configuration file, judge whether this port is recorded in subapplication example list, when certain Single port is recorded in configuration file, but when not being recorded in subapplication example list, determine that this port is for newly-increased port, when certain Single port is recorded in subapplication example list, but when not finding this port in configuration file, determine that this port is deleted in configuration file.
Primary application program judges that configuration file changes, and when determining to there is newly-increased port in configuration file, in order to realize the monitoring to this port, primary application program is according to the path storing subapplication startup file in embodiments of the present invention, for this newly-increased port starts corresponding subapplication example, and determine the mark of this subapplication example, the corresponding relation of the mark of this subapplication and this newly-increased port is saved in subapplication example list.Or, when there is newly-increased port in primary application program determination configuration file, primary application program is according to the path storing subapplication startup file, determine the mark of subapplication to be launched, for this newly-increased port starts corresponding subapplication example, and the corresponding relation of the mark of this subapplication and newly-increased port is saved in subapplication example list.
Primary application program judges that configuration file changes, and when determining that port in configuration file is deleted, because the subapplication corresponding with it is also in the action carrying out monitoring, in order to saving resource, primary application program is according to the information of each port recorded in configuration file in embodiments of the present invention, determine deleted port, and according to each corresponding relation preserved in subapplication example list, determine the subapplication that this deleted port is corresponding, this subapplication is closed, and in subapplication example list, delete the corresponding relation at this deleted port place.
Because primary application program is according to the information of the port in configuration file in embodiments of the present invention, for this port starts corresponding subapplication example, and the corresponding relation of this port and subapplication example is saved in subapplication example list.As long as therefore there is the port in this subapplication example list, be monitored port, now, primary application program is according to the port in each corresponding relation recorded in subapplication example list, judge whether this port is stored in current configuration file, when this port does not exist in current configuration file, determine that this port is deleted, according to the corresponding relation at this port place in this subapplication example list, subapplication example corresponding for this port is deleted, and deletes the corresponding relation at this port place.
In order to ensure that each port can be monitored, the fault that can not occur because of subapplication example, affect normal data reception and the process of port, described method also comprises in embodiments of the present invention:
Described primary application program is according to the time interval of setting, and according to each corresponding relation in described subapplication example list, whether the subapplication example detected in each corresponding relation breaks down;
When there is the Application Instance broken down, the port for this correspondence restarts subapplication example.
The process of a kind of Application Instance listening port that Fig. 3 provides for the embodiment of the present invention two, this process comprises the following steps:
S301: primary application program reads configuration file.
S302: according to the information of port each in configuration file and the path of storage subapplication startup file, be that each port starts corresponding subapplication example.
S303: adopt each subapplication example started to monitor corresponding port.
S304: primary application program is according to the time interval of setting, and according to each corresponding relation in described subapplication example list, whether the subapplication example detected in each corresponding relation breaks down, when judged result is for being, carry out step S305, otherwise, proceed step S304.
S305: the port for this correspondence restarts subapplication example.
Because primary application program in the embodiment of the present invention is according to the time interval of setting, detect for each subapplication example of monitoring whether fault, therefore effectively can ensure that the subapplication example carrying out port monitoring normally runs, without the need to manually restarting subapplication example in this process, and can avoid restarting the consequence that port data receives and process brings caused not in time.
Fig. 4 is the apparatus structure schematic diagram embodiments providing a kind of Application Instance listening port, and described device comprises:
Read module 41, for reading configuration file;
Starting module 42, for according to the information of port each in configuration file and the path of storage subapplication startup file, is that each port starts corresponding subapplication example;
Monitoring module 43, monitoring corresponding port for adopting each subapplication example of startup.
Further, described device also comprises:
Memory module 44, for according to the subapplication example monitoring each port, records the corresponding relation of each port and its subapplication example in subapplication example list.
Further, described device also comprises:
Detection module 45, for monitoring configuration file, judges whether configuration file changes; When configuration file changes, operate accordingly according to the content after configuration file change.
Further, described detection module 45, specifically for when there is newly-increased port in configuration file, primary application program starts new subapplication example and monitors described newly-increased port, and in subapplication example list, record the corresponding relation of this newly-increased port and the new described Application Instance started; When the port in configuration file is deleted, primary application program is according to the corresponding relation recorded in subapplication example list, subapplication example corresponding for described deleted port is closed, and in subapplication example list, deletes the corresponding relation at this port place.
Further, described device also comprises:
Restart module 46, for the time interval according to setting, according to each corresponding relation in described subapplication example list, whether the subapplication example detected in each corresponding relation breaks down; When there is the Application Instance broken down, the port for this correspondence restarts subapplication example.
Embodiments provide a kind of method and device of Application Instance listening port, in the method, primary application program is according to the information of port each in configuration file and the path storing subapplication startup file, for each port starts corresponding subapplication example, and each subapplication example started is adopted to monitor corresponding port.Due in embodiments of the present invention without the need to copying the physical file of subapplication example, decrease the operation to physical file, simple to operate, avoid the possibility producing mistake, and the installation file of subapplication in embodiments of the present invention only need deposit portion, saves storage space.
Intrinsic not relevant to any certain computer, virtual system or miscellaneous equipment with display at this algorithm provided.Various general-purpose system also can with use based on together with this teaching.According to description above, the structure constructed required by this type systematic is apparent.In addition, the present invention is not also for any certain programmed language.It should be understood that and various programming language can be utilized to realize content of the present invention described here, and the description done language-specific is above to disclose preferred forms of the present invention.
In instructions provided herein, describe a large amount of detail.But can understand, embodiments of the invention can be put into practice when not having these details.In some instances, be not shown specifically known method, structure and technology, so that not fuzzy understanding of this description.
Similarly, be to be understood that, in order to simplify the disclosure and to help to understand in each inventive aspect one or more, in the description above to exemplary embodiment of the present invention, each feature of the present invention is grouped together in single embodiment, figure or the description to it sometimes.But, the method for the disclosure should be construed to the following intention of reflection: namely the present invention for required protection requires feature more more than the feature clearly recorded in each claim.Or rather, as claims below reflect, all features of disclosed single embodiment before inventive aspect is to be less than.Therefore, the claims following embodiment are incorporated to this embodiment thus clearly, and wherein each claim itself is as independent embodiment of the present invention.
Those skilled in the art will appreciate that and adaptively can change the module in the equipment in embodiment and they are arranged in one or more equipment different from this embodiment.Module in embodiment or unit or assembly can be combined into a module or unit or assembly, and multiple submodule or subelement or sub-component can be put them in addition.Except at least some in such feature and/or process or unit be mutually repel except, any combination can be adopted to combine all processes of all features disclosed in this instructions (comprising adjoint claim, summary and accompanying drawing) and so disclosed any method or equipment or unit.Unless expressly stated otherwise, each feature disclosed in this instructions (comprising adjoint claim, summary and accompanying drawing) can by providing identical, alternative features that is equivalent or similar object replaces.
In addition, those skilled in the art can understand, although embodiments more described herein to comprise in other embodiment some included feature instead of further feature, the combination of the feature of different embodiment means and to be within scope of the present invention and to form different embodiments.Such as, in the following claims, the one of any of embodiment required for protection can use with arbitrary array mode.
All parts embodiment of the present invention with hardware implementing, or can realize with the software module run on one or more processor, or realizes with their combination.It will be understood by those of skill in the art that the some or all functions that microprocessor or digital signal processor (DSP) can be used in practice to realize according to the some or all parts in the device of the Application Instance listening port of the embodiment of the present invention.The present invention can also be embodied as part or all equipment for performing method as described herein or device program (such as, computer program and computer program).Realizing program of the present invention and can store on a computer-readable medium like this, or the form of one or more signal can be had.Such signal can be downloaded from internet website and obtain, or provides on carrier signal, or provides with any other form.
The present invention will be described instead of limit the invention to it should be noted above-described embodiment, and those skilled in the art can design alternative embodiment when not departing from the scope of claims.In the claims, any reference symbol between bracket should be configured to limitations on claims.Word " comprises " not to be got rid of existence and does not arrange element in the claims or step.Word "a" or "an" before being positioned at element is not got rid of and be there is multiple such element.The present invention can by means of including the hardware of some different elements and realizing by means of the computing machine of suitably programming.In the unit claim listing some devices, several in these devices can be carry out imbody by same hardware branch.Word first, second and third-class use do not represent any order.Can be title by these word explanations.
Obviously, those skilled in the art can carry out various change and modification to the present invention and not depart from the spirit and scope of the present invention.Like this, if these amendments of the present invention and modification belong within the scope of the claims in the present invention and equivalent technologies thereof, then the present invention is also intended to comprise these change and modification.