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
This commit is contained in:
Qstick 2023-01-09 22:14:22 -06:00 committed by Bogdan
parent 55308bef8b
commit f26fd39709
2 changed files with 4 additions and 2 deletions

View file

@ -65,7 +65,7 @@ public virtual void Install(string serviceName)
var args = $"create {serviceName} " +
$"DisplayName= \"{serviceName}\" " +
$"binpath= \"{Process.GetCurrentProcess().MainModule.FileName}\" " +
$"binpath= \"{Environment.ProcessPath}\" " +
"start= auto " +
"depend= EventLog/Tcpip/http " +
"obj= \"NT AUTHORITY\\LocalService\"";

View file

@ -47,7 +47,9 @@ public static void Start(string[] args, Action<IHostBuilder> trayCallback = null
{
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);