From 64c95b81b3ffe72f1c85290c5781e5c7f9ae51fd Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Tue, 19 Mar 2024 21:06:48 +1300 Subject: [PATCH] Fix virtual. --- lib/falcon/command/top.rb | 4 ++++ lib/falcon/command/virtual.rb | 4 +--- lib/falcon/service/proxy.rb | 2 ++ lib/falcon/service/server.rb | 5 +++++ lib/falcon/service/virtual.rb | 16 ++++++++-------- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/falcon/command/top.rb b/lib/falcon/command/top.rb index 3d6d491d..75edb1a0 100644 --- a/lib/falcon/command/top.rb +++ b/lib/falcon/command/top.rb @@ -6,6 +6,8 @@ require_relative 'serve' require_relative 'host' require_relative 'virtual' +require_relative 'proxy' +require_relative 'redirect' require_relative 'supervisor' require_relative '../version' @@ -34,6 +36,8 @@ class Top < Samovar::Command 'serve' => Serve, 'host' => Host, 'virtual' => Virtual, + 'proxy' => Proxy, + 'redirect' => Redirect, 'supervisor' => Supervisor, }, default: 'serve' diff --git a/lib/falcon/command/virtual.rb b/lib/falcon/command/virtual.rb index 028852d1..d1805403 100644 --- a/lib/falcon/command/virtual.rb +++ b/lib/falcon/command/virtual.rb @@ -30,8 +30,6 @@ class Virtual < Samovar::Command # @attribute [Array(String)] many :paths - include Paths - def environment Async::Service::Environment.new(Falcon::Service::Virtual::Environment).with( verbose: self.parent&.verbose?, @@ -43,7 +41,7 @@ def environment end def configuration - super.tap do |configuration| + Async::Service::Configuration.new.tap do |configuration| configuration.add(self.environment) end end diff --git a/lib/falcon/service/proxy.rb b/lib/falcon/service/proxy.rb index b5792762..9b4b05fc 100644 --- a/lib/falcon/service/proxy.rb +++ b/lib/falcon/service/proxy.rb @@ -4,6 +4,8 @@ # Copyright, 2020-2023, by Samuel Williams. require_relative 'server' +require_relative '../tls' +require_relative '../middleware/proxy' require 'async/http/endpoint' require 'async/io/shared_endpoint' diff --git a/lib/falcon/service/server.rb b/lib/falcon/service/server.rb index 91c8b35f..db41a5c1 100644 --- a/lib/falcon/service/server.rb +++ b/lib/falcon/service/server.rb @@ -47,6 +47,11 @@ def cache def client_endpoint ::Async::HTTP::Endpoint.parse(url) end + + # Any scripts to preload before starting the server. + def preload + [] + end end def self.included(target) diff --git a/lib/falcon/service/virtual.rb b/lib/falcon/service/virtual.rb index 08e21fc4..7268b552 100644 --- a/lib/falcon/service/virtual.rb +++ b/lib/falcon/service/virtual.rb @@ -22,7 +22,7 @@ def service_class # All the falcon application configuration paths. # @returns [Array(String)] Paths to the falcon application configuration files. def configuration_paths - File.glob("/srv/http/*/falcon.rb") + ["/srv/http/*/falcon.rb"] end def configuration @@ -128,18 +128,18 @@ def setup(container) container.spawn(name: "Falcon Redirector", restart: true, key: :redirect) do |instance| instance.exec(falcon_path, "redirect", - "--bind", @command.bind_insecure, - "--timeout", @command.timeout.to_s, - "--redirect", @command.bind_secure, - *@command.paths, ready: false + "--bind", evaluator.bind_insecure, + "--timeout", evaluator.timeout.to_s, + "--redirect", evaluator.bind_secure, + *evaluator.configuration_paths, ready: false ) end container.spawn(name: "Falcon Proxy", restart: true, key: :proxy) do |instance| instance.exec(falcon_path, "proxy", - "--bind", @command.bind_secure, - "--timeout", @command.timeout.to_s, - *@command.paths, ready: false + "--bind", evaluator.bind_secure, + "--timeout", evaluator.timeout.to_s, + *evaluator.configuration_paths, ready: false ) end end