Exit non-zero on fault (#1137)
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user