EventStore icon indicating copy to clipboard operation
EventStore copied to clipboard

[CNN-14] Ensure ESDB can run on OSX ARM64

Open RagingKore opened this issue 1 year ago • 0 comments

Added: new UnixSignalManager using PosixSignalRegistration Added: EventStore.SystemRuntime project Removed: EventStore.Common.Utils project and other zombie code Changed: Runtime and Process stats such as CPU Usage and Disk IO

Background and Motivation

Currently we are unable to run ESDB on OSX ARM64 because it breaks on 2 different operations:

Solution

  • New Implementation of the UnixSignalManager using the PosixSignalRegistration
  • New implementation of the breaking metrics removing any dependency on HostStat.NET
  • Removal of leftover code.

Bonus

We now have better metrics coverage as the following metrics are available for the indicated platforms:

  • CPU Usage: Linux*, FreeBSD*, OSX*, Windows
  • CPU Load Averages: Linux, FreeBSD, OSX
  • Disk IO Stats: Linux, Windows and OSX* (read bytes and written bytes only)

Side-quests

The identification of the runtime platform and related operations do not have a single source of truth.

  • We use a Runtime static class that is the single file in the EventStore.Common.Utils project.
  • From the EventStore.Common project we use the OS static class, the OsFlavor enum and the Platforms.GetPlatform
  • The OperatingSystem class from System and even the RuntimeInformation

Given that, a new RuntimeInformation static class providing all the runtime and OS information that was scattered previously, was introduced and it is located in a new Project EventStore.SystemRuntime that will also contain all the new diagnostic information to fix the broken metrics.

namespace EventStore.Common.Utils {
	public static class Runtime {
		public static readonly bool IsUnixOrMac = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) 
			| RuntimeInformation.IsOSPlatform(OSPlatform.OSX);

		public static readonly bool IsWindows = !IsUnixOrMac;

		public static readonly bool IsMacOS = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
	}
}
namespace EventStore.Common.Utils {
	public enum OsFlavor { Unknown, Windows, Linux, BSD, MacOS }

	public class OS {
		public static bool IsUnix {
			get {
				//...
			}
		}

		public static string GetHomeFolder() {
			// ...
		}

		public static string GetRuntimeVersion() {
			// ...
		}
        }
}
namespace EventStore.Common.Utils {
	public class Platforms {
		public static Platform GetPlatform() {
			// ...
		}
	}

	public enum Platform { Windows, Linux, Mac }
}

Notes

Related PR's

resolves #4223

RagingKore avatar May 13 '24 13:05 RagingKore