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