From f26fd397099aa8e4d709931a99491ca354985f6c Mon Sep 17 00:00:00 2001 From: Qstick Date: Mon, 9 Jan 2023 22:14:22 -0600 Subject: [PATCH] Use Environment.ProcessPath instead of GetCurrentProcess().MainModule.FileName GetCurrentProcess().MainModule.FileName is expensive, Environment.ProcessPath added in net6 (cherry picked from commit f928ee7cad304115a002da00e218fb987e02b279) Close #2260 --- src/NzbDrone.Common/ServiceProvider.cs | 2 +- src/NzbDrone.Host/Bootstrap.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Common/ServiceProvider.cs b/src/NzbDrone.Common/ServiceProvider.cs index b3bba75d4..364181697 100644 --- a/src/NzbDrone.Common/ServiceProvider.cs +++ b/src/NzbDrone.Common/ServiceProvider.cs @@ -65,7 +65,7 @@ namespace NzbDrone.Common var args = $"create {serviceName} " + $"DisplayName= \"{serviceName}\" " + - $"binpath= \"{Process.GetCurrentProcess().MainModule.FileName}\" " + + $"binpath= \"{Environment.ProcessPath}\" " + "start= auto " + "depend= EventLog/Tcpip/http " + "obj= \"NT AUTHORITY\\LocalService\""; diff --git a/src/NzbDrone.Host/Bootstrap.cs b/src/NzbDrone.Host/Bootstrap.cs index 8ad9982c3..f3a5b97e6 100644 --- a/src/NzbDrone.Host/Bootstrap.cs +++ b/src/NzbDrone.Host/Bootstrap.cs @@ -47,7 +47,9 @@ namespace NzbDrone.Host { try { - Logger.Info("Starting Readarr - {0} - Version {1}", Assembly.GetCallingAssembly().Location, Assembly.GetExecutingAssembly().GetName().Version); + Logger.Info("Starting Readarr - {0} - Version {1}", + Environment.ProcessPath, + Assembly.GetExecutingAssembly().GetName().Version); var startupContext = new StartupContext(args);