From 3ff30ea1fd638e2c14b7361d1a93eb458c2564a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Ko=C5=BEelj?= Date: Wed, 4 Jan 2023 15:52:45 +0100 Subject: [PATCH] Add command line parameters Add debugger wait --- src/Connected.Host/ConnectedPlatformService.cs | 7 ++++++- src/Connected.Host/Program.cs | 2 ++ src/Connected.Host/sys.json | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Connected.Host/ConnectedPlatformService.cs b/src/Connected.Host/ConnectedPlatformService.cs index 99a8a65..3c09412 100644 --- a/src/Connected.Host/ConnectedPlatformService.cs +++ b/src/Connected.Host/ConnectedPlatformService.cs @@ -1,4 +1,5 @@ -using System.Reflection; +using System.Diagnostics; +using System.Reflection; using Connected.Host.Configuration; using Microsoft.Extensions.Options; @@ -16,6 +17,10 @@ internal sealed class ConnectedPlatformService : BackgroundService protected override async Task ExecuteAsync(CancellationToken stoppingToken) { + if (GlobalConfig.GetValue("waitForDebugger")) + while (!Debugger.IsAttached) + await Task.Delay(500); + await DependencyLoader.LoadPackages(Config.MicroServices, Config.Repositories); if (Type.GetType(Config.Start) is not Type startupType) diff --git a/src/Connected.Host/Program.cs b/src/Connected.Host/Program.cs index 9e0994f..d214fdc 100644 --- a/src/Connected.Host/Program.cs +++ b/src/Connected.Host/Program.cs @@ -11,6 +11,8 @@ namespace Connected.Host .CreateDefaultBuilder(args) .ConfigureAppConfiguration((_, cfg) => { + cfg.AddCommandLine(args); + var appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var segments = new Uri(appPath).Segments; diff --git a/src/Connected.Host/sys.json b/src/Connected.Host/sys.json index bffb95e..876a99b 100644 --- a/src/Connected.Host/sys.json +++ b/src/Connected.Host/sys.json @@ -25,5 +25,6 @@ "version": "1.0.*-*" } ], - "start": "Connected.Instance.Start, Connected.Instance" + "start": "Connected.Instance.Start, Connected.Instance", + "waitForDebugger": true }