Fixed some bugs and added a error handler for the service creation
This commit is contained in:
@@ -102,6 +102,8 @@ public class ServerActions : ServiceActions
|
||||
});
|
||||
}
|
||||
|
||||
serverRepo.Add(server);
|
||||
|
||||
await serverService.Sync(server);
|
||||
await serverService.SendPowerAction(server, PowerAction.Install);
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -47,8 +47,16 @@ 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user