diff --git a/Backend/Program.cs b/Backend/Program.cs index 2df4be43..28859013 100644 --- a/Backend/Program.cs +++ b/Backend/Program.cs @@ -165,6 +165,7 @@ namespace Swarmops.Backend } DateTime cycleStartTime = DateTime.UtcNow; + DateTime cycleEndTime = cycleStartTime.AddSeconds (10); int lastSecond = cycleStartTime.Second; int lastMinute = cycleStartTime.Minute; @@ -226,12 +227,12 @@ namespace Swarmops.Backend lastMinute = cycleStartTime.Minute; lastHour = cycleStartTime.Hour; - // Wait for a maximum of ten seconds + // Wait for a maximum of ten seconds (the difference between cycleStartTime and cycleEndTime - while (DateTime.UtcNow < cycleStartTime.AddSeconds (10) && !exitFlag) + while (DateTime.UtcNow < cycleEndTime && !exitFlag) { - // block until a SIGINT or SIGTERM signal is generated, or one second has passed. - int signalIndex = UnixSignal.WaitAny (killSignals, 1000); + // block until a SIGINT or SIGTERM signal is generated, or 1/4 second has passed. + int signalIndex = UnixSignal.WaitAny (killSignals, 250); if (signalIndex < 1000) { @@ -536,9 +537,7 @@ namespace Swarmops.Backend try { - /*TestTrace("Running InternalPollMaintenance.Run()..."); - InternalPollMaintenance.Run(); - TestTrace(" done.\r\n");*/ + BotLog.DeleteOld (14); // delete logs older than 14 days } catch (Exception e) { diff --git a/Utility/BotCode/BotLog.cs b/Utility/BotCode/BotLog.cs index a0e5530f..fb747a41 100644 --- a/Utility/BotCode/BotLog.cs +++ b/Utility/BotCode/BotLog.cs @@ -31,7 +31,7 @@ namespace Swarmops.Utility.BotCode { DateTime now = DateTime.UtcNow; - string logFileName = "/var/log/swarmops/backend-log-" + + string logFileName = "/var/log/swarmops/backend-" + now.ToString ("yyyy-MM-dd-HH") + ".log"; using (StreamWriter writer = new StreamWriter (logFileName, true, Encoding.GetEncoding (1252))) @@ -39,5 +39,10 @@ namespace Swarmops.Utility.BotCode writer.WriteLine ("[" + now.ToString ("HH:mm:ss.fff") + "] " + message); } } + + public static void DeleteOld (int daysToKeep) + { + // TODO + } } } \ No newline at end of file