Exemplo n.º 1
0
        public async Task <bool> Stop(Server server)
        {
            using (ClaimResource(server.ID))
            {
                try
                {
                    _logger.LogInformation($"About to stop server. ServerID: {server.ID}");

                    await Stop(server.ContainerID);

                    if (server.NeedsRecreate)
                    {
                        await DestroyContainerInternal(server);
                    }

                    _context.Update(server);
                    await _context.SaveChangesAsync();

                    await _infoClient.ServerStopped(server.ID);

                    return(true);
                }
                catch (Exception e)
                {
                    _logger.LogError(new EventId(), e, $"Error occurred when stopping server. ServerID: {server.ID}");

                    return(false);
                }
            }
        }