|
From: creedon <icr...@us...> - 2006-01-07 22:33:44
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/scheduler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30816 Modified Files: monitor Log Message: minor formatting tweaks moved currenttask to temp.scheduler, it is disconcerting to be looking at scheduler table and having currenttask being created and deleted Index: monitor =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/scheduler/monitor,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** monitor 26 Mar 2005 19:43:27 -0000 1.1.1.1 --- monitor 7 Jan 2006 22:33:36 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.scheduler.monitor ! ÇCalled from the agent, once a minute. ÇWe check the task list to see if any are ready to run. ÇIf so, we run it and then check the next task. ÇAbout scheduler.currentTask: ÇBefore your script runs this global is set. ÇYou can use this table to store information between runs, Çscheduler.currentTask^.xxx = 12 ÇChange Notes: ÇSun, 07 Mar 1999 11:25:31 GMT by AR ÇConvert pre-6.0 tasks which are string objects to script objects. Ç12/18/98; 12:05:59 PM by DW ÇMajor rewrite, added logging, scripts can be addresses Ç12/14/98; 11:11:46 PM by DW ÇLogging goes thru log.add ÇMon, Aug 3, 1998 at 5:12:36 PM by PBS ÇRestore oldTarget from within a try (in case it's disappeared). ÇFri, Jul 24, 1998 at 1:06:04 PM by PBS ÇRemoved call to scheduler.init. ÇIt's called from system.startup.startupScript. ÇDon't call target.clear -- instead restore the old target. Ç9/9/99; 6:35:08 PM by DW Çadded support for user.scheduler.threads local (adrtasks = @user.scheduler.tasks, cttasks = sizeOf (adrtasks^), now = clock.now ()); on reschedule (adrtask) { //reschedule the task for another run local (minutesbetweenruns = adrtask^.minutesbetweenruns); if minutesbetweenruns > 0 { Çdon't try to reschedule one-time tasks while now >= adrtask^.tasktime { local (day, month, year, hour, minute, second); date.get (adrtask^.tasktime, @day, @month, @year, @hour, @minute, @second); adrtask^.tasktime = date.set (day, month, year, hour, minute + minutesBetweenRuns, 0)}} else { if minutesbetweenruns == 0 { adrtask^.completed = true}}}; if user.scheduler.prefs.startingup { //confirm that user wants to run awaiting longterm tasks user.scheduler.prefs.startingup = false; local (i); for i = 1 to cttasks { local (adrtask = @adrtasks^ [i]); with adrtask^ { if now >= taskTime { Çit's ready to run local (flreschedule = true); if minutesBetweenRuns > 60 { if user.scheduler.prefs.reschedule { if user.scheduler.prefs.confirmStartupTasks { if dialog.confirm ("Scheduler startup: \"" + nameOf (adrtask^) + "\" is ready to run.") { flreschedule = false}} else { flreschedule = false}}}; //PBS 2/18/99: automatically run the pending tasks if confirmStartupTasks is false (this change is for Frontier servers) if flreschedule { reschedule (adrtask)}}}}}; local (logtable); new (tabletype, @logtable); //globals for all the tasks to share, used in logging local (i, ctran = 0, cterrors = 0, adrtask); for i = 1 to cttasks { //run tasks that are ready adrtask = @adrtasks^ [i]; if now >= adrtask^.taskTime { //it's ready to run adrtask^.ctruns++; scheduler.currentTask = adrtask; //global, available to task try { on callWithLogging (adrscript) { new (tabletype, @logtable.taskInfo); try { callScript (string (adrscript), {}, @logtable)} else { logtable.taskinfo.scriptError = tryError}; table.rename (@logtable.taskInfo, string (adrscript))}; case typeof (adrtask^.script) { scripttype { callWithLogging (@adrtask^.script)}; addresstype { local (nomad = adrtask^.script); while typeof (nomad^) != scripttype { nomad = nomad^}; callWithLogging (nomad)}} else { //convert a pre-6.0 scheduled task from string type to script type and run it local (adrscript = @adrtask^.script); script.newScriptObject (string (adrscript^), adrscript); script.compile (adrscript); //make sure it is valid UserTalk callWithLogging (adrscript)}; adrtask^.error = ""; reschedule (adrtask)} else { adrtask^.error = tryError; cterrors++}; ctran++}}; if defined (scheduler.currentTask) { delete (@scheduler.currentTask)}; bundle { //delete one-time tasks that have been run local (i); for i = cttasks downto 1 { //delete one-time tasks that have been run local (adrtask = @adrtasks^ [i]); if defined (adrtask^.completed) { //a one-time task that's done delete (adrtask)}}}; bundle { //do logging if ctran > 0 { if user.scheduler.prefs.keepLog { local (item = { "Ran " + ctran + " tasks"}); if cterrors > 0 { local (i); item [1] = item [1] + ". " + cterrors + " errors."; for i = cttasks downto 1 { local (errorstring = adrtasks^ [i].error); if errorstring != "" { local (s = nameOf (adrtasks^ [i]) + ": " + errorstring); item = item + {s}}}}; log.add (item, "schedulerMonitor")}; if user.scheduler.prefs.logInGuestDatabase { log.addToGuestDatabase ("schedulerMonitor", flHourlyRoll:true)^ = logtable}}}; bundle { //start threads that need starting, keep threads running scheduler.monitorThreads ()} \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.scheduler.monitor ! ÇChanges Ç1/7/06; 1:59:50 PM by TAC Çminor formatting tweaks Çmoved currenttask to temp.scheduler, it is disconcerting to be looking at scheduler table and having currenttask being created and deleted Ç9/9/99; 6:35:08 PM by DW Çadded support for user.scheduler.threads ÇSun, 07 Mar 1999 11:25:31 GMT by AR ÇConvert pre-6.0 tasks which are string objects to script objects. Ç1998 Ç12/18/98; 12:05:59 PM by DW ÇMajor rewrite, added logging, scripts can be addresses Ç12/14/98; 11:11:46 PM by DW ÇLogging goes thru log.add ÇMon, Aug 3, 1998 at 5:12:36 PM by PBS ÇRestore oldTarget from within a try (in case it's disappeared). ÇFri, Jul 24, 1998 at 1:06:04 PM by PBS ÇRemoved call to scheduler.init. ÇIt's called from system.startup.startupScript. ÇDon't call target.clear -- instead restore the old target. ÇCalled from the agent, once a minute. ÇWe check the task list to see if any are ready to run. ÇIf so, we run it and then check the next task. ÇAbout scheduler.currentTask: ÇBefore your script runs this global is set. ÇYou can use this table to store information between runs, Çscheduler.currentTask^.xxx = 12 local (adrTasks = @user.scheduler.tasks, ctTasks = sizeOf (adrTasks^), now = clock.now ()); on reschedule (adrTask) { //reschedule the task for another run local (minutesbetweenruns = adrTask^.minutesbetweenruns); if minutesbetweenruns > 0 { Çdon't try to reschedule one-time tasks while now >= adrTask^.tasktime { local (day, month, year, hour, minute, second); date.get (adrTask^.tasktime, @day, @month, @year, @hour, @minute, @second); adrTask^.tasktime = date.set (day, month, year, hour, minute + minutesBetweenRuns, 0)}} else { if minutesbetweenruns == 0 { adrTask^.completed = true}}}; if user.scheduler.prefs.startingup { //confirm that user wants to run awaiting longterm tasks user.scheduler.prefs.startingup = false; local (i); for i = 1 to ctTasks { local (adrTask = @adrTasks^ [i]); with adrTask^ { if now >= taskTime { Çit's ready to run local (flreschedule = true); if minutesBetweenRuns > 60 { if user.scheduler.prefs.reschedule { if user.scheduler.prefs.confirmStartupTasks { if dialog.confirm ("Scheduler startup: \"" + nameOf (adrTask^) + "\" is ready to run.") { flreschedule = false}} else { flreschedule = false}}}; //PBS 2/18/99: automatically run the pending tasks if confirmStartupTasks is false (this change is for Frontier servers) if flreschedule { reschedule (adrTask)}}}}}; local (logTable); new (tabletype, @logTable); //globals for all the tasks to share, used in logging local (i, ctRan = 0, ctErrors = 0, adrTask); if not (defined (system.temp.scheduler)) { new (tableType, @system.temp.scheduler)}; for i = 1 to ctTasks { //run tasks that are ready adrTask = @adrTasks^ [i]; if now >= adrTask^.taskTime { //it's ready to run system.temp.scheduler.currentTask = adrTask; //global, available to task adrTask^.ctruns++; try { on callWithLogging (adrScript) { new (tabletype, @logTable.taskInfo); try { callScript (string (adrScript), {}, @logTable)} else { logTable.taskinfo.scriptError = tryError}; table.rename (@logTable.taskInfo, string (adrScript))}; case typeof (adrTask^.script) { scripttype { callWithLogging (@adrTask^.script)}; addresstype { local (nomad = adrTask^.script); while typeof (nomad^) != scripttype { nomad = nomad^}; callWithLogging (nomad)}} else { //convert a pre-6.0 scheduled task from string type to script type and run it local (adrScript = @adrTask^.script); script.newScriptObject (string (adrScript^), adrScript); script.compile (adrScript); //make sure it is valid UserTalk callWithLogging (adrScript)}; adrTask^.error = ""; reschedule (adrTask)} else { adrTask^.error = tryError; ctErrors++}; ctRan++}; }; if defined (system.temp.scheduler.currentTask) { delete (@system.temp.scheduler.currentTask)}; bundle { //delete one-time tasks that have been run local (i); for i = ctTasks downto 1 { //delete one-time tasks that have been run local (adrTask = @adrTasks^ [i]); if defined (adrTask^.completed) { //a one-time task that's done delete (adrTask)}}}; bundle { //do logging if ctRan > 0 { if user.scheduler.prefs.keepLog { local (item = { "Ran " + ctRan + " tasks"}); if ctErrors > 0 { local (i); item [1] = item [1] + ". " + ctErrors + " errors."; for i = ctTasks downto 1 { local (errorstring = adrTasks^ [i].error); if errorstring != "" { local (s = nameOf (adrTasks^ [i]) + ": " + errorstring); item = item + {s}}}}; log.add (item, "schedulerMonitor")}; if user.scheduler.prefs.logInGuestDatabase { log.addToGuestDatabase ("schedulerMonitor", flHourlyRoll:true)^ = logTable}}}; bundle { //start threads that need starting, keep threads running scheduler.monitorThreads ()} \ No newline at end of file |