Support paused containers

This commit is contained in:
Roberto Alsina 2024-06-28 20:57:04 -03:00
parent d276c91f22
commit 897b2dd59e

View File

@ -71,6 +71,16 @@ module Faaso
return 0
end
# If it is paused, unpause it
paused = containers.select { |c|
c.@image == tag && c.@state == "paused"
}
if (paused.size > 0)
puts "Resuming existing paused container"
docker_api.containers.unpause(paused[0].@id)
return 0
end
# If it is exited, start it
existing = containers.select { |c|
c.@image == tag && c.@state == "exited"
@ -80,7 +90,11 @@ module Faaso
if (existing.size > 0)
puts "Restarting existing exited container"
docker_api.containers.start(existing[0].@id)
else
return 0
end
# Creating from scratch
puts "Creating new container"
conf = Docr::Types::CreateContainerConfig.new(
image: tag,
hostname: "foo",
@ -95,7 +109,6 @@ module Faaso
# TODO: Return function URL for testing
end
end
end
class Down
@arguments : Array(String) = [] of String