Update OnScheduler issues.
This commit is contained in:
parent
1297722c6a
commit
b7ab52690e
4 changed files with 54 additions and 33 deletions
|
@ -2132,6 +2132,7 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
TaskManager.WriteError(ex);
|
TaskManager.WriteError(ex);
|
||||||
|
res.IsSuccess = false;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,9 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
|
|
||||||
public sealed class Scheduler
|
public sealed class Scheduler
|
||||||
{
|
{
|
||||||
static SchedulerJob nextSchedule = null;
|
public static SchedulerJob nextSchedule = null;
|
||||||
|
|
||||||
// main timer
|
// main timer and put it to sleep
|
||||||
static Timer scheduleTimer = new Timer(new TimerCallback(RunNextSchedule),
|
static Timer scheduleTimer = new Timer(new TimerCallback(RunNextSchedule),
|
||||||
null,
|
null,
|
||||||
Timeout.Infinite,
|
Timeout.Infinite,
|
||||||
|
@ -92,6 +92,8 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
// this will put the timer to sleep
|
// this will put the timer to sleep
|
||||||
scheduleTimer.Change(Timeout.Infinite, Timeout.Infinite);
|
scheduleTimer.Change(Timeout.Infinite, Timeout.Infinite);
|
||||||
|
|
||||||
|
System.Threading.Thread.Sleep(1000);
|
||||||
|
|
||||||
// run immediately
|
// run immediately
|
||||||
RunNextSchedule(null);
|
RunNextSchedule(null);
|
||||||
}
|
}
|
||||||
|
@ -121,6 +123,10 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RunSchedule(SchedulerJob schedule, bool changeNextRun)
|
static void RunSchedule(SchedulerJob schedule, bool changeNextRun)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// update next run (if required)
|
// update next run (if required)
|
||||||
if (changeNextRun)
|
if (changeNextRun)
|
||||||
|
@ -142,11 +148,17 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
SchedulerController.UpdateSchedule(schedule.ScheduleInfo);
|
SchedulerController.UpdateSchedule(schedule.ScheduleInfo);
|
||||||
|
|
||||||
// skip execution if the current task is still running
|
// skip execution if the current task is still running
|
||||||
if (scheduledTasks.ContainsKey(schedule.ScheduleInfo.ScheduleId))
|
scheduledTasks = TaskManager.GetScheduledTasks();
|
||||||
return;
|
if (!scheduledTasks.ContainsKey(schedule.ScheduleInfo.ScheduleId))
|
||||||
|
{
|
||||||
// run the schedule in the separate thread
|
// run the schedule in the separate thread
|
||||||
schedule.Run();
|
schedule.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception Ex)
|
||||||
|
{
|
||||||
|
TaskManager.WriteError(string.Format("RunSchedule Error : {0}", Ex.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,8 +150,8 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
{
|
{
|
||||||
// ERROR
|
// ERROR
|
||||||
WriteLogRecord(2, ex.Message, ex.StackTrace);
|
WriteLogRecord(2, ex.Message, ex.StackTrace);
|
||||||
return new Exception(String.Format("Error executing '{0}' task on '{1}' {2}",
|
return new Exception((TopTask != null) ? String.Format("Error executing '{0}' task on '{1}' {2}",
|
||||||
TopTask.TaskName, TopTask.ItemName, TopTask.Source), ex);
|
TopTask.TaskName, TopTask.ItemName, TopTask.Source) : String.Format("Error executing task"), ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WriteError(Exception ex, string text, params string[] textParameters)
|
public static void WriteError(Exception ex, string text, params string[] textParameters)
|
||||||
|
@ -182,6 +182,8 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
logRecord.TextParameters = textParameters;
|
logRecord.TextParameters = textParameters;
|
||||||
logRecord.TextIdent = TasksStack.Count - 1;
|
logRecord.TextIdent = TasksStack.Count - 1;
|
||||||
logRecord.ExceptionStackTrace = stackTrace;
|
logRecord.ExceptionStackTrace = stackTrace;
|
||||||
|
if (RootTask != null)
|
||||||
|
{
|
||||||
RootTask.LogRecords.Add(logRecord);
|
RootTask.LogRecords.Add(logRecord);
|
||||||
RootTask.LastLogRecord = logRecord;
|
RootTask.LastLogRecord = logRecord;
|
||||||
|
|
||||||
|
@ -189,6 +191,7 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
if (severity > RootTask.Severity)
|
if (severity > RootTask.Severity)
|
||||||
RootTask.Severity = severity;
|
RootTask.Severity = severity;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void CompleteTask()
|
public static void CompleteTask()
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,8 +46,13 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
|
|
||||||
protected void Application_Start(object sender, EventArgs e)
|
protected void Application_Start(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (ConfigurationManager.AppSettings["WebsitePanel.DistableScheduler"] != null)
|
||||||
|
if (Boolean.Parse(ConfigurationManager.AppSettings["WebsitePanel.DistableScheduler"]) == false)
|
||||||
|
{
|
||||||
|
if (Scheduler.nextSchedule == null)
|
||||||
Scheduler.Start();
|
Scheduler.Start();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void Application_End(object sender, EventArgs e)
|
protected void Application_End(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue