Fix proxy config confusion
This commit is contained in:
parent
3b2297e954
commit
665b4f9ab7
6
TODO.md
6
TODO.md
@ -14,9 +14,9 @@
|
||||
* ✅ Nodejs + Express
|
||||
* Create a site
|
||||
* Document
|
||||
* How to create a runtime
|
||||
* How to create a funko
|
||||
* How to setup the proxy
|
||||
* FaaSO for app developers
|
||||
* FaaSO for runtime developers
|
||||
* FaaSO server setup
|
||||
* APIs
|
||||
* Sanitize all inputs
|
||||
* ✅ Streaming responses in slow operations like scaling down
|
||||
|
@ -44,10 +44,6 @@ shards:
|
||||
git: https://github.com/mamantoha/http_proxy.git
|
||||
version: 0.10.3
|
||||
|
||||
inotify:
|
||||
git: https://github.com/petoem/inotify.cr.git
|
||||
version: 1.0.3
|
||||
|
||||
kemal:
|
||||
git: https://github.com/kemalcr/kemal.git
|
||||
version: 1.5.0
|
||||
|
@ -30,8 +30,6 @@ dependencies:
|
||||
docr:
|
||||
github: ralsina/docr
|
||||
branch: add_exposed_ports
|
||||
inotify:
|
||||
github: petoem/inotify.cr
|
||||
kemal:
|
||||
github: kemalcr/kemal
|
||||
kemal-basic-auth:
|
||||
|
@ -1,16 +1,11 @@
|
||||
require "./funko.cr"
|
||||
require "docr"
|
||||
require "inotify"
|
||||
require "kemal"
|
||||
|
||||
module Proxy
|
||||
CADDY_CONFIG_PATH = "config/funkos"
|
||||
@@current_config = File.read(CADDY_CONFIG_PATH)
|
||||
|
||||
@@watcher = Inotify.watch(CADDY_CONFIG_PATH) do |_|
|
||||
Log.info { "Reloading caddy config" }
|
||||
Process.run(command: "caddy", args: ["reload", "--config", CADDY_CONFIG_PATH])
|
||||
end
|
||||
CADDY_CONFIG_PATH = "config/Caddyfile"
|
||||
CADDY_CONFIG_FUNKOS = "config/funkos"
|
||||
@@current_config = File.read(CADDY_CONFIG_FUNKOS)
|
||||
|
||||
# Get current proxy config
|
||||
get "/proxy/" do
|
||||
@ -25,7 +20,7 @@ module Proxy
|
||||
update_proxy_config
|
||||
end
|
||||
|
||||
def self.update_proxy_config
|
||||
def self.update_proxy_config : Nil
|
||||
docker_api = Docr::API.new(Docr::Client.new)
|
||||
containers = docker_api.containers.list(all: true)
|
||||
|
||||
@ -50,13 +45,13 @@ module Proxy
|
||||
|
||||
if @@current_config != config
|
||||
Log.info { "Updating proxy config" }
|
||||
File.open(CADDY_CONFIG_PATH, "w") do |file|
|
||||
File.open(CADDY_CONFIG_FUNKOS, "w") do |file|
|
||||
file << config
|
||||
end
|
||||
# Reload config
|
||||
@@current_config = config
|
||||
Process.run(command: "caddy", args: ["reload", "--config", CADDY_CONFIG_PATH])
|
||||
end
|
||||
config
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user