Compare commits

..

No commits in common. "ead5cfdcc642bb60ab1b00fb22e536f13ed62311" and "eb6d63a5336934f3c0ded0e7cc866e684344574f" have entirely different histories.

4 changed files with 16 additions and 7 deletions

View File

@ -91,8 +91,7 @@ module Funko
end end
if env.params.query.fetch("format", "json") == "html" if env.params.query.fetch("format", "json") == "html"
render "src/views/funkos.ecr" render "src/views/funkos.ecr" else
else
result.to_json result.to_json
end end
end end

View File

@ -1,5 +1,5 @@
require "./funko.cr" require "./funko.cr"
require "./proxy.cr" require "./proxyconf.cr"
require "./secrets.cr" require "./secrets.cr"
require "./terminal.cr" require "./terminal.cr"
require "compress/gzip" require "compress/gzip"

View File

@ -1,5 +1,5 @@
require "docr" require "docr"
require "./funko.cr" require "funko"
require "kemal" require "kemal"
module Proxy module Proxy

View File

@ -178,12 +178,11 @@ module Funko
end end
end end
# Get all running containers related to this funko # Get all containers related to this funko
def containers def containers
docker_api = Docr::API.new(Docr::Client.new) docker_api = Docr::API.new(Docr::Client.new)
docker_api.containers.list(all: true).select { |container| docker_api.containers.list(all: true).select { |container|
container.@names.any?(&.starts_with?("/faaso-#{name}-")) && container.@names.any?(&.starts_with?("/faaso-#{name}-"))
container.@state == "running"
} }
end end
@ -207,6 +206,17 @@ module Funko
end end
end end
# Stop container with the newer image
def stop
docker_api = Docr::API.new(Docr::Client.new)
images = self.image_history
containers = self.containers.sort! { |i, j|
(images.index(j.@image_id) || 9999) <=> (images.index(i.@image_id) || 9999)
}
return docker_api.containers.stop(containers[0].@id) unless containers.empty?
nil
end
# Wait up to `t` seconds for the funko to reach the requested `state` # Wait up to `t` seconds for the funko to reach the requested `state`
def wait_for(new_scale : Int, t) def wait_for(new_scale : Int, t)
channel = Channel(Nil).new channel = Channel(Nil).new