Compare commits

..

3 Commits

Author SHA1 Message Date
ead5cfdcc6 Cleanup 2024-07-04 17:02:34 -03:00
35283a0aea containers only returns running containers 2024-07-04 17:02:27 -03:00
496230c4d3 Dead code 2024-07-04 16:57:41 -03:00
4 changed files with 7 additions and 16 deletions

View File

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

View File

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

View File

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

View File

@ -178,11 +178,12 @@ module Funko
end
end
# Get all containers related to this funko
# Get all running containers related to this funko
def containers
docker_api = Docr::API.new(Docr::Client.new)
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
@ -206,17 +207,6 @@ module Funko
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`
def wait_for(new_scale : Int, t)
channel = Channel(Nil).new