Background technology
Different according to applied environment on server, can start different process.In a large amount of processes, can exist independent separately, boot sequence, each process not affecting of end order, also exist boot sequence and end order interrelated, some process need to just can normally start after other processes have started, some process need to just can normally close after other processes have started simultaneously.Common practices, is when coding, to consider the interdependence of process, and needs at code layer, to carry out design and corresponding realization in advance.The process that conventional method cannot not have the executable file of source code to produce for some is carried out interrelated, and when actual application environment and demand generation change, need to again do a large amount of designs and coding work at code layer.
On server, generally adopting multiprocessor and every processor is at present all a plurality of physics cores, it is even more that the process number that separate unit server can carry can reach processes up to a hundred, if applied environment changes, according to conventional method, need again at code layer, to modify, workload is heavy, if operation manually, workload can be quite large, and manually operated human error also can increase.
Therefore, provide that customizable relies on, easy-to-use, the wscript.exe of simplifying manual operation, just seem and be of practical significance very much.
Summary of the invention
Technical assignment of the present invention is to solve the deficiencies in the prior art, and a kind of automatized script instrument is provided.
Technical scheme of the present invention realizes in the following manner, this kind of automatized script instrument, and implementation step is:
1) script obtains current time stamp when operation, reads user preset dependence and stand-by period w;
2) take process name and add timestamp as name, create journal file, and make file in appending the state writing;
3) to move the mode of subprocess, start the current process in list and return to immediately script;
4) after stand-by period w, detecting step 3), started state of a process, state can be: operation or off-duty;
5) 4) if in the state that detects be off-duty, point out and exit script; If the state detecting is operation, to next process in default process list, the mode with operation subprocess starts process and returns to immediately script;
6) repeating step 3)~5), until all processes in the presets list are all activated;
7) read process in user preset dependence and finish list;
8) continue the current process state in detection list, until state is off-duty;
9) according to the order that finishes list, finish next process, and continue to detect the process status of end operation effect, until state is off-duty;
10) repeating step 9), until all processes that finish in list are all moved to end.
In described step 1), preset dependence and comprise that a process initiation list and process finish list, wherein
Process initiation list is to comprise the process name that all needs start, by the sequencing of required startup, arranges, and former and later two adjacent processes, a rear process depends on previous process and starts, and in normal operation;
It is to comprise the process name that all needs start that process finishes list, by the sequencing of required end, arrange, and former and later two adjacent processes, a rear process depends on previous process and finishes.
Stand-by period in described step 1) starts completely for waiting process, and this time is greater than the maximal value of maximum start-up time and maximum end time in process list.
The beneficial effect that the present invention compared with prior art produced is:
A kind of automatized script instrument of the present invention, by the presetting of dependence, is realized the customizable relying on, thereby when change occurs for actual application environment and demand, changes fast, meets new demand.Do not need again code layer to be designed and changed.Practical, applied widely, be easy to promote.
Embodiment
Below a kind of automatized script instrument of the present invention is described in detail below.
The present invention is by designing a wscript.exe, for automatic phasing mutual correlation process, according to the boot sequence that meets the demands such as application, function, start, whether and it is normal automatically to detect per stage startup, as normally, by the order of presetting according to user, start next process, as certain one-phase finishes after starting unsuccessfully or starting fast, to provide prompting, as follow-up phase all relies on normal startup and the work of this stage process, script is by prompting and exit.The process, process number and the mutual relationship that start can be preset according to user's demand.Wscript.exe can automatic phasing mutual correlation process sequentially finish according to the end that meets the demands such as application, function equally, and automatically detect per stage and finish whether success, as success, by the order of presetting according to user, finish next process, as certain one-phase, to finish process unsuccessful, will provide prompting, as follow-up phase all relies on the end of this stage process, script is by prompting and exit.The specific implementation step of wscript.exe provided by the invention is:
1) script obtains current time stamp when operation, reads user preset dependence and stand-by period w.
By system function, directly obtain timestamp, if do not supported direct acquisition, current time calculates current time stamp, read in the predefined process initiation list of user, and current operation process is set to the first process of process initiation list.
2) take process name and add timestamp as name, create journal file, and make file in appending the state writing.
3) to move the mode of subprocess, start the current process in list and return to immediately script.Mode with operation subprocess starts current process, and unblock mode is used in operation, can return to immediately script like this after operation.
4) after stand-by period w, detecting step 3), started state of a process, state can be: operation or off-duty; By default, after stand-by period w, detect in (3) and started state of a process.
5) if the state detecting is off-duty, point out and exit script in step 4); If the state detecting is operation, to next process in default process list, the mode with operation subprocess starts process and returns to immediately script; As the state detecting is for moving, and next process in default process list is started process and returns to immediately script to move the mode of subprocess.
6) repeating step 3)~5), until all processes in the presets list are all activated, with the process in the mode that circulates successively operating list, when circulation finishes, all processes are all activated or wrong returning.
7) read process in user preset dependence and finish list.
8) continue the current process state in detection list, until state is off-duty, continues to detect and use obstruction mode to operate, do not return immediately, until the state detecting is off-duty, just return to script.
9) according to the order that finishes list, finish next process, and continue to detect the process status of end operation effect, until state is off-duty.
10) repeating step 9), until all processes that finish in list are all moved to end.Closing journal file afterwards, script finishes.
In described step 1), preset dependence and comprise that a process initiation list and process finish list, wherein
Process initiation list is to comprise the process name that all needs start, by the sequencing of required startup, arranges, and former and later two adjacent processes, a rear process depends on previous process and starts, and in normal operation.
It is to comprise the process name that all needs start that process finishes list, by the sequencing of required end, arrange, and former and later two adjacent processes, a rear process depends on previous process and finishes.
Stand-by period in described step 1) starts completely for waiting process, and this time is greater than the maximal value of maximum start-up time and maximum end time in process list.
The present invention is the automatized script instrument for interrelated process initiation and end, it is the process that can be used for automatically opening and finishing to have relation of interdependence, as two process A, B, process A need to start prior to process B, and the normal need of work of process B guarantees that A has started and normally operation, the present invention can arrange after the boot sequence and dependence of process A and process B user, according to preset order, start, and meeting self-verifying process status, to determine whether default dependence meets, assurance process A, B all can be by pre-conditioned, normal work.The present invention is not only applicable to two interrelated processes, is equally applicable to a plurality of processes that are mutually related.
Automatized script instrument feature of the present invention is can the process in arbitrarily default dependence be started and be finished by its dependence, can customize arbitrarily, operation automation
The foregoing is only embodiments of the invention, within the spirit and principles in the present invention all, any modification of doing, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.