Skip to content

Commit

Permalink
Ensure the container is stopped if it's not correctly started.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Mar 25, 2024
1 parent 9fb616f commit ebf6f83
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/async/container/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,20 @@ def restart
raise SetupError, container
end

# Make this swap as atomic as possible:
# The following swap should be atomic:
old_container = @container
@container = container
container = nil

if old_container
Console.logger.debug(self, "Stopping old container...")
old_container&.stop
end

Console.logger.debug(self, "Stopping old container...")
old_container&.stop
@notify&.ready!
rescue
ensure
# If we are leaving this function with an exception, try to kill the container:
container&.stop(false)

raise
end

# Reload the existing container. Children instances will be reloaded using `SIGHUP`.
Expand Down

0 comments on commit ebf6f83

Please sign in to comment.