Background technology
It is different according to applied environment on the server, different process can be started.Can exist each in a large amount of processes
It is independent, the process that boot sequence, end order respectively do not affect, while there is also boot sequence and end order is interrelated, i.e.,
Some processes needs just can normally start after other processes have been started up finishing, some processes are needed in other processes
It is activated finish after just can normal switching-off.Common practices, is that the interdependence of process is considered in coding, and is needed pre-
First carry out design and corresponding realization in code layer.Conventional method cannot for some do not have source code executable file produce enter
Cheng Jinhang is interrelated, and when actual application environment and demand are changed, needs do substantial amounts of setting again in code layer
Meter and coding work.
Generally it is at present multiple physical cores using multiprocessor and per processor on server, single server institute energy
To can reach processes up to a hundred even more more for the number of passes that enters for carrying, if applied environment changes, according to conventional method needs again
Modify in code layer, workload is heavy, if manual hand manipulation, the artificial mistake that workload can be quite big, manually operated
Mistake also can increase.
Therefore it provides customizable dependence, wscript.exe that is easy-to-use, simplifying manual operation, just seem there is very much actual meaning
Justice.
The content of the invention
The technical assignment of the present invention is to solve the deficiencies in the prior art, there is provided a kind of automatized script instrument.
The technical scheme is that what is realized in the following manner, a kind of automatized script instrument, implementation step is:
1)Script operationally obtains current time stamp, reads user preset dependence and stand-by period w;
2)Added timestamp as name with process name, create journal file, and make state of the file in write can be added;
3)Start the current process in list in the way of to run subprocess and return script immediately;
4)After stand-by period w, detecting step 3) in have been turned on state of a process, state can be:Operation or off-duty;
5)4)In if the state for detecting be off-duty, then pointed out and exited script;If the shape for detecting
State is operation, then to next process in default process list to run subprocess in the way of launching process and return pin immediately
This;
6)Repeat step 3)~5), all processes in the presets list are activated;
7)Read process in user preset dependence and terminate list;
8)The current process state in list is persistently detected, until state is off-duty;
9)According to the order for terminating list, terminate next process, and persistently detect the process status that end operation is acted on,
Until state is off-duty;
10)Repeat step 9), until terminate list in all processes be moved to end.
The step 1)In preset dependence and terminate list including a process initiation list and process, wherein
Process initiation list is the process name comprising institute's startup in need, by the sequencing arrangement of required startup, and phase
Former and later two adjacent processes, latter process depends on previous process to have been started up, and is normally running;
It is the process name comprising institute's end in need that process terminates list, by the sequencing arrangement of required end, and phase
Former and later two adjacent processes, latter process depends on previous process to be over.
The step 1)In stand-by period start completely for waiting process, the time opens more than maximum in process list
Dynamic time and the maximum of maximum end time.
The produced compared with prior art beneficial effect of the present invention is:
A kind of automatized script instrument of the present invention realizes the customizable of dependence by presetting to dependence
Change, so as to when actual application environment and demand are changed, quickly be changed, meet new demand.Need not be again to generation
Code layer is designed and changes.It is practical, it is applied widely, it is easy to promote.
Specific embodiment
A kind of automatized script instrument of the present invention is described in detail below below.
The present invention is by designing a wscript.exe, for automatic phasing mutual correlation process according to satisfaction application, function
Started etc. the boot sequence of demand, and normally whether automatic detection start per the stage, it is such as normal, will preset according to user
Order, start next process, the such as a certain stage starts failure or quickly terminates after starting, will be given and point out and exit.Open
Dynamic process, enter number of passes and correlation and can be preset according to the demand of user.Wscript.exe equally can automatic phasing it is mutual
Association process is terminated according to application, the end of the demand such as function order is met, and automatic detection per the stage terminate whether into
Work(, such as success, will terminate next process according to the default order of user, and such as to terminate process unsuccessful a certain stage, will give
Go out prompting, such as follow-up phase all relies on the end of this stage process, and script will be prompted to and exit.The wscript.exe that the present invention is provided
The step that implements be:
1)Script operationally obtains current time stamp, reads user preset dependence and stand-by period w.
Timestamp is directly obtained by system function, if do not supported to directly obtain, current time carries out being calculated currently
Timestamp, reads in user's process initiation list set in advance, and current operation process is set to into the head of process initiation list
Individual process.
2)Added timestamp as name with process name, create journal file, and make state of the file in write can be added.
3)Start the current process in list in the way of to run subprocess and return script immediately.To run subprocess
Mode starts current process, operates with non-blocking fashion, and after so operating script can be immediately returned.
4)After stand-by period w, detecting step 3) in have been turned on state of a process, state can be:Operation or off-duty;By pre-
If after stand-by period w, in detection (3) state of a process is had been turned on.
5)In step 4)In if the state for detecting be off-duty, then pointed out and exited script;If detected
State be operation, then to next process in default process list to run subprocess in the way of launching process and return immediately
Bend backwards sheet;The state for such as detecting is operation, then to next process in default process list to run subprocess in the way of
Launching process simultaneously returns immediately script.
6)Repeat step 3)~5), all processes in the presets list are activated, grasp successively in a circulating manner
Make the process in list, at the end of circulation, all processes are activated or wrong return.
7)Read process in user preset dependence and terminate list.
8)The current process state in list is persistently detected, until state is off-duty, persistently detection uses obstruction mode
Operation, does not return immediately, until the state for detecting just returns script for off-duty.
9)According to the order for terminating list, terminate next process, and persistently detect the process status that end operation is acted on,
Until state is off-duty.
10)Repeat step 9), until terminate list in all processes be moved to end.Closing journal file afterwards, script
Terminate.
The step 1)In preset dependence and terminate list including a process initiation list and process, wherein
Process initiation list is the process name comprising institute's startup in need, by the sequencing arrangement of required startup, and phase
Former and later two adjacent processes, latter process depends on previous process to have been started up, and is normally running.
It is the process name comprising institute's end in need that process terminates list, by the sequencing arrangement of required end, and phase
Former and later two adjacent processes, latter process depends on previous process to be over.
The step 1)In stand-by period start completely for waiting process, the time opens more than maximum in process list
Dynamic time and the maximum of maximum end time.
The present invention is the automatized script instrument for interrelated process initiation and end, be can be used to automatically turning on and
Terminate the process with relation of interdependence, such as two processes A, B, process A needs to start prior to process B, and process B is just
Often need of work ensures that A has been started up and normally runs, and the present invention can arrange the boot sequence of process A and process B in user
After dependence, started according to preset order, and can automatically be checked process status, whether to determine default dependence
Meet, it is ensured that process A, B can be by pre-conditioned, normal work.The present invention is applicable not only to two interrelated processes, equally
Suitable for multiple processes that are mutually related.
The automatized script instrument feature of the present invention is that the process in any default dependence can be relied on by it
Started and terminated, can arbitrarily be customized, operation automation
The foregoing is only embodiments of the invention, it is all within the spirit and principles in the present invention, made it is any
Modification, equivalent, improvement etc., should be included within the scope of the present invention.