Exit non-zero on fault (#1137)
.NET Build and Publish / build-windows (push) Has been cancelled
.NET Build and Publish / build-linux (push) Has been cancelled
.NET Build and Publish / deploy-installers (push) Has been cancelled

This commit is contained in:
Jedd Morgan
2025-10-06 11:35:49 +01:00
committed by GitHub
parent 58c6370cda
commit 656ed709f3
2 changed files with 15 additions and 2 deletions
@@ -10,16 +10,27 @@ namespace Speckle.Importers.JobProcessor;
public static class Program
{
public static async Task Main(string[] args)
public static async Task<int> Main(string[] args)
{
// Dapper doesn't understand how to handle JSON deserialization, so we need to tell it what types can be deserialzied
SqlMapper.AddTypeHandler(new JsonHandler<FileimportPayload>());
var host = ConfigureAppHost(args);
ConfigureTopLevelLogs(host.Services.GetRequiredService<ILogger<object>>());
var backgroundServiceTasks = host
.Services.GetServices<IHostedService>()
.OfType<BackgroundService>()
.Select(s => s.ExecuteTask);
await host.RunAsync();
if (backgroundServiceTasks.Any(t => t?.IsFaulted == true))
{
//https://github.com/dotnet/runtime/issues/67146
return -1;
}
return 0;
}
private static IHost ConfigureAppHost(string[] args)
@@ -52,6 +52,8 @@ internal sealed class ImporterInstance(Sender sender, ILogger<ImporterInstance>
try
{
using var config = GetConfig(Path.GetExtension(args.FilePath));
logger.LogInformation("Opening file {FilePath}", args.FilePath);
_rhinoDoc = config.OpenInHeadlessDocument(args.FilePath);
RhinoDoc.ActiveDoc = _rhinoDoc;