Skip to content

Commit

Permalink
b3115 Shutdown improvements when running as a Linux service
Browse files Browse the repository at this point in the history
  • Loading branch information
mcrossley committed Feb 24, 2021
1 parent 82089ad commit 35fa803
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CumulusMX/Cumulus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,8 @@ public Cumulus(int HTTPport, bool DebugEnabled, string startParms)
{
// no response wait 10 seconds before trying again
Thread.Sleep(10000);
// Force a DNS refresh
Dns.GetHostEntry(ProgramOptions.StartupPingHost);
}
} while ((reply == null || reply.Status != IPStatus.Success) && DateTime.Now < endTime);

Expand Down
4 changes: 2 additions & 2 deletions CumulusMX/DavisStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1593,12 +1593,12 @@ private void GetAndProcessLoopData(int number)
StormRain = ConvertRainClicksToUser(loopData.StormRain);
StartOfStorm = loopData.StormRainStart;

if (loopData.UVIndex >= 0 && loopData.UVIndex < 25)
if (loopData.UVIndex >= 0 && loopData.UVIndex < 17)
{
DoUV(loopData.UVIndex, now);
}

if (loopData.SolarRad >= 0 && loopData.SolarRad < 5000)
if (loopData.SolarRad >= 0 && loopData.SolarRad < 1801)
{
DoSolarRad(loopData.SolarRad, now);
}
Expand Down
24 changes: 21 additions & 3 deletions CumulusMX/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,23 @@ private static void Main(string[] args)
// Wait for a signal to be delivered
unixSignalWaitAny?.Invoke(null, new object[] {signals});

var msg = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff ") + "Exiting system due to external SIGTERM signal";
Console.WriteLine(msg);
svcTextListener.WriteLine(msg);

if (cumulus != null)
{
cumulus.LogConsoleMessage("\nExiting system due to external SIGTERM signal");
msg = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff ") + "Cumulus terminating";
Console.WriteLine(msg);
svcTextListener.WriteLine(msg);
cumulus.LogMessage("Exiting system due to external SIGTERM signal");
cumulus.LogMessage("Cumulus terminating");
cumulus.Stop();
//allow main to run off
Thread.Sleep(500);
msg = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff ") + "Cumulus has shutdown";
Console.WriteLine(msg);
svcTextListener.WriteLine(msg);
}

exitSystem = true;
Expand All @@ -88,6 +102,8 @@ private static void Main(string[] args)
cumulus.LogConsoleMessage("Ctrl+C pressed");
cumulus.LogConsoleMessage("\nCumulus terminating");
cumulus.Stop();
//allow main to run off
Thread.Sleep(500);
}
Trace.WriteLine("Cumulus has shutdown");
ev.Cancel = true;
Expand Down Expand Up @@ -283,6 +299,8 @@ private static void UnhandledExceptionTrapper(object sender, UnhandledExceptionE
}
}


// Windows ExitHandler
public class ExitHandler
{
[DllImport("Kernel32")]
Expand Down Expand Up @@ -319,6 +337,8 @@ private static bool Handler(CtrlType sig)
{
Program.cumulus.LogConsoleMessage("Cumulus terminating");
Program.cumulus.Stop();
//allow main to run off
Thread.Sleep(500);
}
else
{
Expand All @@ -329,8 +349,6 @@ private static bool Handler(CtrlType sig)
Trace.WriteLine("Cumulus has shutdown");
Console.WriteLine("Cumulus stopped");

//allow main to run off
Thread.Sleep(200);
Program.exitSystem = true;

return true;
Expand Down
6 changes: 3 additions & 3 deletions CumulusMX/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Cumulus MX")]
[assembly: AssemblyDescription("Build 3114")]
[assembly: AssemblyDescription("Build 3115")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Cumulus MX")]
Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.10.0.3114")]
[assembly: AssemblyFileVersion("3.10.0.3114")]
[assembly: AssemblyVersion("3.10.0.3115")]
[assembly: AssemblyFileVersion("3.10.0.3115")]
4 changes: 3 additions & 1 deletion Updates.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
3.10.0 - b3114
3.10.0 - b3115
——————————————
- Fix: Catch error creating System Uptime counter on Windows
- Fix: The Local web server is now brought up before initialising the station. This allows you to correct a misconfigured station without resorting to editing the Cumulus.ini file.
- Fix: Diary Editor creating entries on the wrong day, and revamp the interface a bit
- Fix: WLL day average temp stats on historic catch-up
- Fix: GW1000 auto-discovery was triggering an erroneous IP address change
- Fix: Cumulus MX shutdown when running as a system service is now orderly
- Fix: The start-up ping now refreshes the DNS cache before every re-try to avoid using null entries cached before the internet comes up

- New: Brand new default web site template courtesy of Neil Thomas. The original "legacy" web site is still included, but it has been moved to the /webfiles-legacy folder.
- The new web site is now data file driven as opposed to all pages being processed and uploaded. The legacy web site has also been updated to use this method.
Expand Down

0 comments on commit 35fa803

Please sign in to comment.