Fixed some bugs and added a error handler for the service creation

This commit is contained in:
Marcel Baumgartner
2024-01-30 22:42:07 +01:00
parent aaee81e9c4
commit 681403ec6e
4 changed files with 15 additions and 5 deletions

View File

@@ -102,6 +102,8 @@ public class ServerActions : ServiceActions
});
}
serverRepo.Add(server);
await serverService.Sync(server);
await serverService.SendPowerAction(server, PowerAction.Install);
}

View File

@@ -14,7 +14,7 @@ public class Server
public ServerImage Image { get; set; }
public int DockerImageIndex { get; set; }
public string? OverrideStartupCommand { get; set; }
public List<ServerVariable> Variables { get; set; }
public List<ServerVariable> Variables { get; set; } = new();
public ServerNode Node { get; set; }
public ServerAllocation MainAllocation { get; set; }

View File

@@ -48,7 +48,7 @@ public class ServerService
.First(x => x.Id == server.Id);
var protocol = serverWithNode.Node.UseSsl ? "https" : "http";
var remoteUrl = $"{protocol}://{serverWithNode.Node.Fqdn}/";
var remoteUrl = $"{protocol}://{serverWithNode.Node.Fqdn}:{serverWithNode.Node.HttpPort}/";
return new HttpApiClient<NodeException>(remoteUrl, serverWithNode.Node.Token);
}

View File

@@ -47,9 +47,17 @@ public class ServiceAdminService
// Add new service in database
var finishedService = serviceRepo.Add(service);
// Call the action for the logic behind the service type
await impl.Actions.Create(scope.ServiceProvider, finishedService);
try
{
// Call the action for the logic behind the service type
await impl.Actions.Create(scope.ServiceProvider, finishedService);
}
catch (Exception) // Handle any implementation errors and let the creation fail
{
serviceRepo.Delete(finishedService);
throw;
}
return finishedService;
}