Fix bootstrap

pull/4/head
Ogoun 2 years ago
parent c69a588b01
commit 06dc99456f

@ -29,6 +29,10 @@ namespace ZeroLevel
public BootstrapFluent(IZeroService service) public BootstrapFluent(IZeroService service)
{ {
if (service == null)
{
throw new ArgumentNullException(nameof(service));
}
_service = service; _service = service;
} }
@ -45,7 +49,15 @@ namespace ZeroLevel
public IServiceExecution Run() public IServiceExecution Run()
{ {
_service.Start(); try
{
_service?.Start();
}
catch (Exception ex)
{
Log.Error(ex, $"[Bootstrap] Service {_service?.Name} run error");
return null;
}
return this; return this;
} }
@ -119,7 +131,7 @@ namespace ZeroLevel
Func<bool> postStartConfiguration = null) Func<bool> postStartConfiguration = null)
where T : IZeroService where T : IZeroService
{ {
var service = Initialize<T>(args, Configuration.ReadSetFromApplicationConfig(), var service = Initialize<T>(args, null,
preStartConfiguration, postStartConfiguration); preStartConfiguration, postStartConfiguration);
return new BootstrapFluent(service); return new BootstrapFluent(service);
} }
@ -130,7 +142,7 @@ namespace ZeroLevel
Func<bool> postStartConfiguration = null) Func<bool> postStartConfiguration = null)
where T : IZeroService where T : IZeroService
{ {
var service = Initialize<T>(args, configuration(), preStartConfiguration, postStartConfiguration); var service = Initialize<T>(args, configuration?.Invoke(), preStartConfiguration, postStartConfiguration);
return new BootstrapFluent(service); return new BootstrapFluent(service);
} }
@ -143,8 +155,12 @@ namespace ZeroLevel
IZeroService service = null; IZeroService service = null;
IConfigurationSet config = Configuration.DefaultSet; IConfigurationSet config = Configuration.DefaultSet;
config.CreateSection("commandline", Configuration.ReadFromCommandLine(args)); config.CreateSection("commandline", Configuration.ReadFromCommandLine(args));
if (configurationSet != null)
{
config.Merge(configurationSet); config.Merge(configurationSet);
}
Log.CreateLoggingFromConfiguration(Configuration.DefaultSet); Log.CreateLoggingFromConfiguration(Configuration.DefaultSet);
if (preStartConfiguration != null) if (preStartConfiguration != null)
{ {
try try

@ -6,16 +6,16 @@
</Description> </Description>
<Authors>ogoun</Authors> <Authors>ogoun</Authors>
<Company>ogoun</Company> <Company>ogoun</Company>
<AssemblyVersion>3.3.9.2</AssemblyVersion> <AssemblyVersion>3.3.9.3</AssemblyVersion>
<PackageReleaseNotes>Partition storage. DropCache method</PackageReleaseNotes> <PackageReleaseNotes>Update Bootstrap</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/ogoun/Zero/wiki</PackageProjectUrl> <PackageProjectUrl>https://github.com/ogoun/Zero/wiki</PackageProjectUrl>
<Copyright>Copyright Ogoun 2023</Copyright> <Copyright>Copyright Ogoun 2023</Copyright>
<PackageLicenseUrl></PackageLicenseUrl> <PackageLicenseUrl></PackageLicenseUrl>
<PackageIconUrl></PackageIconUrl> <PackageIconUrl></PackageIconUrl>
<RepositoryUrl>https://github.com/ogoun/Zero</RepositoryUrl> <RepositoryUrl>https://github.com/ogoun/Zero</RepositoryUrl>
<RepositoryType>git</RepositoryType> <RepositoryType>git</RepositoryType>
<Version>3.3.9.2</Version> <Version>3.3.9.3</Version>
<FileVersion>3.3.9.2</FileVersion> <FileVersion>3.3.9.3</FileVersion>
<Platforms>AnyCPU;x64;x86</Platforms> <Platforms>AnyCPU;x64;x86</Platforms>
<PackageIcon>zero.png</PackageIcon> <PackageIcon>zero.png</PackageIcon>
<DebugType>full</DebugType> <DebugType>full</DebugType>

Loading…
Cancel
Save

Powered by TurnKey Linux.