From 29d3c399ac0e12bb4d4e73d9db3aff06db15ab93 Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Thu, 4 Jul 2024 20:24:27 -0300 Subject: [PATCH] Per-instance shell/logs --- src/daemon/funko.cr | 20 ++++++-------------- src/daemon/main.cr | 2 +- src/views/funkos.ecr | 4 ++-- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/daemon/funko.cr b/src/daemon/funko.cr index 5f708c6..836f589 100644 --- a/src/daemon/funko.cr +++ b/src/daemon/funko.cr @@ -125,24 +125,16 @@ module Funko end # Return an iframe that shows the container's logs - get "/funkos/:name/terminal/logs" do |env| - name = env.params.url["name"] - funko = Funko.from_names([name])[0] - # FIXME: Just getting the 1st one for now, it - # may not even be running - container_name = funko.containers.map { |c| c.@names[0] }[0] - Terminal.start_terminal(["docker", "logs", "-f", container_name.to_s]) + get "/funkos/terminal/logs/:instance/" do |env| + instance = env.params.url["instance"] + Terminal.start_terminal(["docker", "logs", "-f", instance]) "" end # Get an iframe with a shell into the container - get "/funkos/:name/terminal/shell" do |env| - name = env.params.url["name"] - funko = Funko.from_names([name])[0] - # FIXME: Just getting the 1st one for now, it - # may not even be running - container_name = funko.containers.map { |c| c.@names[0] }[0].lstrip("/") - Terminal.start_terminal(["docker", "exec", "-ti", container_name, "/bin/sh"], readonly: false) + get "/funkos/terminal/shell/:instance/" do |env| + instance = env.params.url["instance"] + Terminal.start_terminal(["docker", "exec", "-ti", instance, "/bin/sh"], readonly: false) "" end diff --git a/src/daemon/main.cr b/src/daemon/main.cr index bfc2948..00fe620 100644 --- a/src/daemon/main.cr +++ b/src/daemon/main.cr @@ -13,7 +13,7 @@ require "uuid" basic_auth "admin", "admin" get "/" do |env| - env.redirect "index.html" + env.redirect "/index.html" end Kemal.run diff --git a/src/views/funkos.ecr b/src/views/funkos.ecr index 62e399b..e4219a2 100644 --- a/src/views/funkos.ecr +++ b/src/views/funkos.ecr @@ -23,8 +23,8 @@ <%- end -%> - - + + <%- end -%>