Do some pruning when scaling

This commit is contained in:
Roberto Alsina 2024-07-03 15:30:09 -03:00
parent 126cae6c18
commit e618f7c9e6

View File

@ -99,7 +99,6 @@ module Funko
Log.info { "Adding instance" } Log.info { "Adding instance" }
(current_scale...new_scale).each { (current_scale...new_scale).each {
id = create_container id = create_container
sleep 0.2.seconds
start(id) start(id)
} }
else else
@ -112,6 +111,12 @@ module Funko
break if current_scale == new_scale break if current_scale == new_scale
} }
end end
# And now, let's kill all the containers that are NOT running
containers.select { |container| container.@state != "running" }.each { |container|
Log.info { "Pruning dead instance" }
docker_api.containers.delete(container.@id)
}
end end
# Setup the target directory `path` with all the files needed # Setup the target directory `path` with all the files needed