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