diff --git a/TODO.md b/TODO.md index 53c2a42..1751261 100644 --- a/TODO.md +++ b/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 diff --git a/shard.lock b/shard.lock index b3ba9c6..1e5f2a1 100644 --- a/shard.lock +++ b/shard.lock @@ -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 diff --git a/shard.yml b/shard.yml index a41b552..af7bb65 100644 --- a/shard.yml +++ b/shard.yml @@ -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: diff --git a/src/daemon/proxy.cr b/src/daemon/proxy.cr index f801eab..71878ba 100644 --- a/src/daemon/proxy.cr +++ b/src/daemon/proxy.cr @@ -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