From 06dc99456f5444869973f8dfd1c6bfd9243bcfe0 Mon Sep 17 00:00:00 2001 From: Ogoun Date: Mon, 23 Jan 2023 18:22:47 +0300 Subject: [PATCH] Fix bootstrap --- ZeroLevel/Services/Bootstrap.cs | 24 ++++++++++++++++++++---- ZeroLevel/ZeroLevel.csproj | 8 ++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ZeroLevel/Services/Bootstrap.cs b/ZeroLevel/Services/Bootstrap.cs index 630da96..c0e861c 100644 --- a/ZeroLevel/Services/Bootstrap.cs +++ b/ZeroLevel/Services/Bootstrap.cs @@ -29,6 +29,10 @@ namespace ZeroLevel public BootstrapFluent(IZeroService service) { + if (service == null) + { + throw new ArgumentNullException(nameof(service)); + } _service = service; } @@ -45,7 +49,15 @@ namespace ZeroLevel public IServiceExecution Run() { - _service.Start(); + try + { + _service?.Start(); + } + catch (Exception ex) + { + Log.Error(ex, $"[Bootstrap] Service {_service?.Name} run error"); + return null; + } return this; } @@ -119,7 +131,7 @@ namespace ZeroLevel Func postStartConfiguration = null) where T : IZeroService { - var service = Initialize(args, Configuration.ReadSetFromApplicationConfig(), + var service = Initialize(args, null, preStartConfiguration, postStartConfiguration); return new BootstrapFluent(service); } @@ -130,7 +142,7 @@ namespace ZeroLevel Func postStartConfiguration = null) where T : IZeroService { - var service = Initialize(args, configuration(), preStartConfiguration, postStartConfiguration); + var service = Initialize(args, configuration?.Invoke(), preStartConfiguration, postStartConfiguration); return new BootstrapFluent(service); } @@ -143,8 +155,12 @@ namespace ZeroLevel IZeroService service = null; IConfigurationSet config = Configuration.DefaultSet; config.CreateSection("commandline", Configuration.ReadFromCommandLine(args)); - config.Merge(configurationSet); + if (configurationSet != null) + { + config.Merge(configurationSet); + } Log.CreateLoggingFromConfiguration(Configuration.DefaultSet); + if (preStartConfiguration != null) { try diff --git a/ZeroLevel/ZeroLevel.csproj b/ZeroLevel/ZeroLevel.csproj index 68130df..959febf 100644 --- a/ZeroLevel/ZeroLevel.csproj +++ b/ZeroLevel/ZeroLevel.csproj @@ -6,16 +6,16 @@ ogoun ogoun - 3.3.9.2 - Partition storage. DropCache method + 3.3.9.3 + Update Bootstrap https://github.com/ogoun/Zero/wiki Copyright Ogoun 2023 https://github.com/ogoun/Zero git - 3.3.9.2 - 3.3.9.2 + 3.3.9.3 + 3.3.9.3 AnyCPU;x64;x86 zero.png full