A kind of monitoring of computer applied algorithm and abnormality eliminating method
Technical field
The present invention relates to a kind of method for supervising of computer program.
Background technology
Computer applied algorithm is because inner or outside, occurs that defective is difficult to avoid.When defective occurred, it is uncertain unusual that application program is taken place, and withdraws from or do not have a response such as program.If application program is an application program that the interface is arranged, when program exception, the user can be restarted program and guarantees that application program normally moves by manual; If application program is the application program at a no interface, only when the user can't use the application service that application program provides, just can learn program exception.For general application program, program may not have too big problem unusually, but for some special application scenario, such as the application that can not interrupt the long time, program will cause bigger influence unusually.
Chinese patent application " computer application software opens method from the error correction deadweight " (CN03100776.7) provides a kind of computer application software to open method from the error correction deadweight, it can make application program make mistakes in uncertain situation and withdraw from or when not having response, can close the process of makeing mistakes automatically, and open new process copy again, the assurance system is long-time normally to be moved.This method comprises creates an external progress, during system start-up, external progress starts earlier, and create and start the internal process of application software by external progress, external progress is termly to the request of internal process status report, under the normal situation of internal process, the abnormality processing module of internal process is made correct to the status report request that external progress sent and is fed back timely; When improper withdraw from or when stopping to respond, if external progress can not receive feedback information in a period of time always, then external progress sends termination messages or directly stops internal process internal process, and sets up a new internal process automatically appears in internal process.
But, because general application program all is made up of multimode,, might cause whole application crash if some modules are unusual, also might only cause a certain function to realize.Whether " computer application software opens method from error correction deadweight " can only application programs integral body be monitored unusually, and whether each module that can't application programs is monitored unusually.If it is unusual that certain module in the internal process of application program occurs, but the abnormality processing module is normal, still can handle the status report request of external progress, then this method just can not guarantee the operate as normal of application program fully.
Summary of the invention
The object of the invention provides a kind of monitoring and abnormality eliminating method of computer applied algorithm, its not only can application programs duty monitor, and each module monitored, and can handle program exception, solved existing method for supervising and can not monitor technical matters with abnormality processing respectively each module.
Technical solution of the present invention is:
A kind of monitoring of computer applied algorithm and abnormality eliminating method may further comprise the steps:
Step 1] start monitoring process: for application program is created a monitoring process and start this monitoring process before being started this application program;
Step 2] start application process: after monitoring process started, whether the inquiry application process started, if be not activated, monitoring process at first starts application process;
Step 3] inquiry application process status information: if application process starts, the regular application processes transmit status of monitoring process query requests then, after application process is received status query request, collect corresponding status information, and status information is fed back to monitoring process;
Step 4] processing of program exception: if can not receive the application process feedack in the time of setting always, or information feedback is unusual, and then monitoring process sends termination message or directly stops this application process, and starts this application process;
Described step 1] start the monitoring process step and specifically comprise: for application program is created a monitoring process and start this monitoring process before being started this application program; This monitoring process comprises that response is set to be indicated: monitoring process inside is provided with the response sign of each module of application process and application process self, the error accumulation numerical value of each module and application process itself in its judgement application process, monitoring process sends a status query request, and all response signs just increase by 1;
Described step 3] monitoring process regularly specifically comprises to application process transmit status query requests step: monitoring process every the regular hour to application process transmit status query requests, move under the normal situation in application process, each module of application process and application process all can be made correctly and timely the status query request that monitoring process sends and feeding back, and monitoring process indicates zero setting with each corresponding response;
Described step 4] in time of setting comprise in start-up time and outer start-up time, start-up time is than outer start-up time of weak point in this;
Described step 4] in program abnormity processing step comprise:
1] if monitoring process can not receive the feedback information of application process in the interior start-up time of setting always, perhaps certain module does not have feedback information or feedback information unusual, and then monitoring process sends termination message or directly stops this application process;
2] if application process can't stop, then monitoring process can not receive the feedback information of application process always in the outer start-up time of setting, and when perhaps certain module did not have feedback information or feedback information unusual, monitoring process directly started this application process.
Above-mentioned steps 3] in the status query request that sends of monitoring process application processes comprise: application program is collected the status information of each module.
Above-mentioned steps 3] in the status query request that sends of monitoring process application processes comprise: application program is collected the status information of application program self and the status information of each module.
Above-mentioned application process receives that the status information of collecting application program self after the status query request comprises: work at present content, network connect whether unobstructed, database connect whether unobstructed, handle request number, operation starting time or update time.
Above-mentioned steps 4] in start-up time be the interior startup threshold value of response sign, the outer startup threshold value that indicate for response described outer start-up time; Described step 4] treatment step of program exception specifically comprises: if in the monitoring process, the super outer startup threshold value of setting that do not surpass of the error accumulation numerical value of some response signs, but when surpassing interior startup threshold value, then monitoring process sends termination message or directly stops this application process, if application process still can't stop, this new application process was restarted in the operation of monitoring process forced termination application process when error accumulation numerical value that then should response sign surpassed the outer startup threshold value of setting.
Above-mentioned steps 3] in monitoring process show corresponding state information after receiving the status information of feedback.
Above-mentioned monitoring process comprises communication mechanism and wrong mechanism for correcting errors: communication mechanism is to be responsible for sending request and receiving feedback information with application process, and it can be by message transmission, shared drive, write configuration file, write registration table, pipeline, socket communication mode are realized the communication between monitoring process and the application process; The mistake mechanism for correcting errors be responsible for to communications reception to information analyze and handle.
Advantage of the present invention is:
1, in this method; monitoring process not only application programs itself is monitored; and each module of energy application programs is monitored; under the situation of application program operate as normal; can in time find the collapse or the abnormal conditions of certain module; and carry out respective handling, application program is better worked long hours and move.
If a particular module in 2 application programs has great importance, this method can be monitored this module separately when application programs is monitored, to guarantee the normal operation of application program to greatest extent.
3, the different operating situation that the present invention is directed to application process has been carried out respective handling, and when application process is improper when withdrawing from or stopping to respond, monitoring process requires the application process oneself to close and restarts, and is equivalent to warm start or interior startup; The oneself closes and when restarting, monitoring process is closed by force and restarted application process when application process can't be carried out, and is equivalent to cold start-up or outer the startup.The step that starts in the present invention has increased by one, can reduce to greatest extent outer start that application programs brings such as adverse effects such as loss of datas, guarantee the normal operation of application program.
Description of drawings
Fig. 1 is a system schematic of the present invention;
Fig. 2 is that monitoring process of the present invention and application process start process flow diagram;
Fig. 3 is normal workflow figure of the present invention;
Fig. 4 is the process flow diagram of application process of the present invention when unusual;
Fig. 5 is the process flow diagram of a certain module of application process of the present invention when unusual.
Embodiment
System schematic of the present invention is seen Fig. 1, application program comprises monitoring process and application process, application process comprises module 1, module 2 ... module n, communication between monitoring process and the application process comprises status query request and feedback of status, and the communication between application process and each module comprises enquiry module state request and module status feedback.For the one or more particular modules that have great importance in the application programs are monitored, also can directly carry out the communication process of enquiry module state request and module status feedback between monitoring process and each module.
Watchdog routine of the present invention and application process start flow process and see Fig. 2, comprise creating a monitoring process, and after monitoring process started, whether the inquiry application process started, if be not activated, start application process earlier, carry out the initialization system state.Timer (timer is provided with and will regularly be triggered according to the user) is set when starting application process.
Normal workflow of the present invention is seen Fig. 3, and monitoring process at first starts application process after starting.Monitoring process is provided with timer, to judge the response of application process; Whether timer is triggered at every turn, all can inquire about application process and start, if be not activated, then starts application process.After timer is triggered, to application process transmit status query requests, monitoring process inside is provided with the response sign of each module of application process and application process itself, it is used for judging the error accumulation numerical value of each module of application process and application process itself, monitoring process sends a status query request, and all response signs just increase by 1.After application process is received status query request, collect the status information of self and the status information of each module, comprise work at present content, network connect whether unobstructed, database connect whether unobstructed, handle request number, operation starting time or update time etc., and give monitoring process with these information feedback, monitoring process shows these information.Move under the normal situation in application process, each module of application process and application process all can be made correctly and timely the status query request that monitoring process sends and be fed back the zero setting that monitoring process indicates each corresponding response.
Flow process when application process is unusual is seen Fig. 4, if monitoring process can not receive the monitor message of application process feedback always, perhaps the monitor message of application process is unusual, such as the error accumulation count value of response sign greater than 10, then monitoring process sends termination message or directly stops application process, and sets up a new application process automatically.
Flow process when a certain module of application process is unusual is seen Fig. 5, if monitoring process can not receive the monitor message of certain module always, perhaps the monitor message of certain module is unusual, such as the error accumulation count value of response sign greater than 10, then monitoring process sends termination message or directly stops application process, or sets up a new application process automatically.
The principle of the invention:
Application process of the present invention is finished application program major function, task.
Monitoring process of the present invention is responsible for monitoring the normal operation of application process: comprise communication mechanism and wrong mechanism for correcting errors.Communication mechanism is to be responsible for sending request and receiving feedback information with application process.Modes such as it can be by message transmission, shared drive, write configuration file, write registration table, pipeline, socket communication realize the communication between monitoring process and the application process.The mistake mechanism for correcting errors be responsible for to communications reception to information analyze and handle.
The mistake mechanism for correcting errors further comprises the feedback message that sends that judges whether on time to receive application process:
If 1 does not receive the feedback message that application process is sent in the time of setting, check then whether application process exists, if application process exists, think that then application process is unusual or enter deadlock, just send and stop application process message, close application process, and restart an application process, if application process does not exist, then directly start an application process;
Though 2 receive the feedback message that application process sends, in the feedback message, some modules do not have feedback information, then send to application process and stop process message, close application process, and restart an application process.
Start-up time and outer start-up time in the time of setting comprises, start-up time is shorter than outer start-up time in this; Be the interior startup threshold value of response sign interior start-up time, be the outer startup threshold value of response sign outer start-up time.
Communication mechanism further comprises to application process transmit status query requests, move under the normal situation in application process, each module of internal process and internal process all can be made correctly and timely the status query request that monitoring process sends and being fed back, and monitoring process indicates zero setting with each corresponding response.Mechanism for correcting errors further comprises if the error accumulation numerical value of some response signs does not surpass the outer threshold value (such as 10) that starts, but when surpassing interior startup threshold value (such as 5), then allow the application process oneself close, if application process can't the oneself be closed oneself, then the error accumulation numerical value of response sign surpasses forced termination application process operation when starting threshold value (such as 10) outward, restarts the step of a new application process.
In this method; not only application programs itself is monitored; and each module of application programs is monitored; solved application program to a great extent because certain module collapse or when unusual; whole application program can not operate as normal problem, can make more healthy and stronger the working long hours and moving of application program.