falcon 0.42.3 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bake/falcon/supervisor.rb +3 -1
- data/changes.md +22 -0
- data/lib/falcon/command/host.rb +7 -50
- data/lib/falcon/command/paths.rb +2 -19
- data/lib/falcon/command/proxy.rb +21 -33
- data/lib/falcon/command/redirect.rb +22 -33
- data/lib/falcon/command/serve.rb +44 -82
- data/lib/falcon/command/supervisor.rb +2 -19
- data/lib/falcon/command/top.rb +2 -19
- data/lib/falcon/command/virtual.rb +16 -41
- data/lib/falcon/command.rb +3 -19
- data/lib/falcon/configuration.rb +28 -142
- data/lib/falcon/endpoint.rb +2 -19
- data/lib/falcon/environment/application.rb +60 -0
- data/lib/falcon/environment/lets_encrypt_tls.rb +34 -0
- data/lib/falcon/environment/proxy.rb +109 -0
- data/lib/falcon/environment/rack.rb +20 -0
- data/lib/falcon/environment/rackup.rb +26 -0
- data/lib/falcon/environment/redirect.rb +50 -0
- data/lib/falcon/environment/self_signed_tls.rb +45 -0
- data/lib/falcon/environment/server.rb +69 -0
- data/lib/falcon/environment/supervisor.rb +40 -0
- data/lib/falcon/environment/tls.rb +97 -0
- data/lib/falcon/environment.rb +13 -0
- data/lib/falcon/middleware/proxy.rb +3 -20
- data/lib/falcon/middleware/redirect.rb +2 -19
- data/lib/falcon/middleware/verbose.rb +2 -19
- data/lib/falcon/proxy_endpoint.rb +2 -19
- data/lib/falcon/railtie.rb +10 -0
- data/lib/falcon/server.rb +2 -19
- data/lib/falcon/service/server.rb +84 -0
- data/lib/falcon/service/supervisor.rb +5 -21
- data/lib/falcon/{controller → service}/virtual.rb +72 -36
- data/lib/falcon/tls.rb +2 -19
- data/lib/falcon/version.rb +3 -20
- data/lib/falcon.rb +5 -19
- data/lib/rack/handler/falcon.rb +4 -0
- data/lib/rackup/handler/falcon.rb +83 -0
- data/license.md +41 -0
- data/readme.md +60 -0
- data.tar.gz.sig +0 -0
- metadata +37 -117
- metadata.gz.sig +0 -0
- data/lib/.DS_Store +0 -0
- data/lib/falcon/controller/host.rb +0 -72
- data/lib/falcon/controller/proxy.rb +0 -126
- data/lib/falcon/controller/redirect.rb +0 -76
- data/lib/falcon/controller/serve.rb +0 -126
- data/lib/falcon/environments/application.rb +0 -72
- data/lib/falcon/environments/lets_encrypt_tls.rb +0 -47
- data/lib/falcon/environments/proxy.rb +0 -37
- data/lib/falcon/environments/rack.rb +0 -50
- data/lib/falcon/environments/self_signed_tls.rb +0 -55
- data/lib/falcon/environments/supervisor.rb +0 -51
- data/lib/falcon/environments/tls.rb +0 -103
- data/lib/falcon/environments.rb +0 -31
- data/lib/falcon/service/application.rb +0 -115
- data/lib/falcon/service/generic.rb +0 -78
- data/lib/falcon/service/proxy.rb +0 -66
- data/lib/falcon/services.rb +0 -99
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: deaf700b8a46f5af5e6e1151c0a0708789add0c2e66f4d6048e17da5e7da8c84
|
4
|
+
data.tar.gz: bac8d213a65f15c4bcc0741e86f357f1158ff2fedacb9480a00ce7ea3498de64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40c405c0e768f68b1a4c56cbf7f155571240b30e8079051243e354596e32db76593929352ca70799d13cedd0fa1fe13afbbfb54edf6d1b0cb0c65d3edf7ea349
|
7
|
+
data.tar.gz: 9a94416a4b3f82cc34fe61e5b0cf1bdc23ab6c2190ed37d95ff11a9cfb4dfee204c855245d03715cd0d5b63f439451200752240bca2dce58336adc8f84b0c422
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/bake/falcon/supervisor.rb
CHANGED
data/changes.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Changes
|
2
|
+
|
3
|
+
# v0.44.0
|
4
|
+
|
5
|
+
## Falcon Host
|
6
|
+
|
7
|
+
`async-service` is a new gem that exposes a generic service interface on top of `async-container`. Previously, `falcon host` used `async-container` directly and `build-environment` for configuration. In order to allow for more generic service definitions and configuration, `async-service` now provides a similar interface to `build-environment` and exposes this in a way that can be used for services other tha falcon. This makes it simpler to integrate multiple services into a single application.
|
8
|
+
|
9
|
+
The current configuration format uses definitions like this:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
rack 'hello.localhost', :self_signed_tls
|
13
|
+
```
|
14
|
+
|
15
|
+
This changes to:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
service 'hello.localhost' do
|
19
|
+
include Falcon::Environment::Rack
|
20
|
+
include Falcon::Environment::SelfSignedTLS
|
21
|
+
end
|
22
|
+
```
|
data/lib/falcon/command/host.rb
CHANGED
@@ -1,31 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
22
5
|
|
23
|
-
require_relative '
|
24
|
-
require_relative '../configuration'
|
6
|
+
require_relative 'paths'
|
25
7
|
require_relative '../version'
|
26
8
|
|
27
9
|
require 'samovar'
|
28
|
-
require '
|
10
|
+
require 'async/service/controller'
|
29
11
|
|
30
12
|
module Falcon
|
31
13
|
module Command
|
@@ -40,28 +22,13 @@ module Falcon
|
|
40
22
|
# @attribute [Array(String)]
|
41
23
|
many :paths, "Service configuration paths.", default: ["falcon.rb"]
|
42
24
|
|
25
|
+
include Paths
|
26
|
+
|
43
27
|
# The container class to use.
|
44
28
|
def container_class
|
45
29
|
Async::Container.best_container_class
|
46
30
|
end
|
47
31
|
|
48
|
-
# Generate a configuration based on the specified {paths}.
|
49
|
-
def configuration
|
50
|
-
configuration = Configuration.new
|
51
|
-
|
52
|
-
@paths.each do |path|
|
53
|
-
path = File.expand_path(path)
|
54
|
-
configuration.load_file(path)
|
55
|
-
end
|
56
|
-
|
57
|
-
return configuration
|
58
|
-
end
|
59
|
-
|
60
|
-
# Prepare a new controller for the command.
|
61
|
-
def controller
|
62
|
-
Controller::Host.new(self)
|
63
|
-
end
|
64
|
-
|
65
32
|
# Prepare the environment and run the controller.
|
66
33
|
def call
|
67
34
|
Console.logger.info(self) do |buffer|
|
@@ -71,17 +38,7 @@ module Falcon
|
|
71
38
|
buffer.puts "- To reload: kill -HUP #{Process.pid}"
|
72
39
|
end
|
73
40
|
|
74
|
-
|
75
|
-
Bundler.require(:preload)
|
76
|
-
rescue Bundler::GemfileNotFound
|
77
|
-
# Ignore.
|
78
|
-
end
|
79
|
-
|
80
|
-
if GC.respond_to?(:compact)
|
81
|
-
GC.compact
|
82
|
-
end
|
83
|
-
|
84
|
-
self.controller.run
|
41
|
+
Async::Service::Controller.run(self.configuration, container_class: self.container_class)
|
85
42
|
end
|
86
43
|
end
|
87
44
|
end
|
data/lib/falcon/command/paths.rb
CHANGED
@@ -1,24 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2020-2023, by Samuel Williams.
|
22
5
|
|
23
6
|
require_relative '../configuration'
|
24
7
|
|
data/lib/falcon/command/proxy.rb
CHANGED
@@ -1,26 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2020-2024, by Samuel Williams.
|
22
5
|
|
23
|
-
require_relative '../
|
6
|
+
require_relative '../environment/proxy'
|
24
7
|
require_relative 'paths'
|
25
8
|
|
26
9
|
require 'samovar'
|
@@ -48,20 +31,21 @@ module Falcon
|
|
48
31
|
|
49
32
|
include Paths
|
50
33
|
|
51
|
-
|
52
|
-
|
53
|
-
|
34
|
+
def environment(**options)
|
35
|
+
Async::Service::Environment.new(Falcon::Environment::Proxy).with(
|
36
|
+
root: Dir.pwd,
|
37
|
+
name: self.class.name,
|
38
|
+
verbose: self.parent&.verbose?,
|
39
|
+
url: @options[:bind],
|
40
|
+
timeout: @options[:timeout],
|
41
|
+
**options
|
42
|
+
)
|
54
43
|
end
|
55
44
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
# Options for the container.
|
62
|
-
# See {Controller::Serve#setup}.
|
63
|
-
def container_options
|
64
|
-
{}
|
45
|
+
def configuration
|
46
|
+
Configuration.for(
|
47
|
+
self.environment(environments: super.environments)
|
48
|
+
)
|
65
49
|
end
|
66
50
|
|
67
51
|
# Prepare the environment and run the controller.
|
@@ -71,9 +55,13 @@ module Falcon
|
|
71
55
|
buffer.puts "- Binding to: #{@options[:bind]}"
|
72
56
|
buffer.puts "- To terminate: Ctrl-C or kill #{Process.pid}"
|
73
57
|
buffer.puts "- To reload: kill -HUP #{Process.pid}"
|
58
|
+
|
59
|
+
self.resolved_paths.each do |path|
|
60
|
+
buffer.puts "- Loading configuration from #{path}"
|
61
|
+
end
|
74
62
|
end
|
75
63
|
|
76
|
-
self.
|
64
|
+
Async::Service::Controller.run(self.configuration)
|
77
65
|
end
|
78
66
|
|
79
67
|
# The endpoint to bind to.
|
@@ -1,26 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2020-2024, by Samuel Williams.
|
22
5
|
|
23
|
-
require_relative '../
|
6
|
+
require_relative '../environment/redirect'
|
24
7
|
require_relative 'paths'
|
25
8
|
|
26
9
|
require 'samovar'
|
@@ -46,20 +29,22 @@ module Falcon
|
|
46
29
|
|
47
30
|
include Paths
|
48
31
|
|
49
|
-
|
50
|
-
|
51
|
-
|
32
|
+
def environment(**options)
|
33
|
+
Async::Service::Environment.new(Falcon::Environment::Redirect).with(
|
34
|
+
root: Dir.pwd,
|
35
|
+
name: self.class.name,
|
36
|
+
verbose: self.parent&.verbose?,
|
37
|
+
url: @options[:bind],
|
38
|
+
redirect_url: @options[:redirect],
|
39
|
+
timeout: @options[:timeout],
|
40
|
+
**options
|
41
|
+
)
|
52
42
|
end
|
53
43
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
# Options for the container.
|
60
|
-
# See {Controller::Serve#setup}.
|
61
|
-
def container_options
|
62
|
-
{}
|
44
|
+
def configuration
|
45
|
+
Configuration.for(
|
46
|
+
self.environment(environments: super.environments)
|
47
|
+
)
|
63
48
|
end
|
64
49
|
|
65
50
|
# Prepare the environment and run the controller.
|
@@ -69,9 +54,13 @@ module Falcon
|
|
69
54
|
buffer.puts "- Binding to: #{@options[:bind]}"
|
70
55
|
buffer.puts "- To terminate: Ctrl-C or kill #{Process.pid}"
|
71
56
|
buffer.puts "- To reload: kill -HUP #{Process.pid}"
|
57
|
+
|
58
|
+
self.resolved_paths.each do |path|
|
59
|
+
buffer.puts "- Loading configuration from #{path}"
|
60
|
+
end
|
72
61
|
end
|
73
62
|
|
74
|
-
self.
|
63
|
+
Async::Service::Controller.run(self.configuration)
|
75
64
|
end
|
76
65
|
|
77
66
|
# The endpoint to bind to.
|
data/lib/falcon/command/serve.rb
CHANGED
@@ -1,42 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
5
|
+
# Copyright, 2018, by Mitsutaka Mimura.
|
22
6
|
|
23
7
|
require_relative '../server'
|
24
8
|
require_relative '../endpoint'
|
25
|
-
require_relative '../
|
9
|
+
require_relative '../configuration'
|
10
|
+
require_relative '../service/server'
|
11
|
+
require_relative '../environment/rackup'
|
26
12
|
|
27
13
|
require 'async/container'
|
28
|
-
|
29
|
-
require 'async/io/trap'
|
30
|
-
require 'async/io/host_endpoint'
|
31
|
-
require 'async/io/shared_endpoint'
|
32
|
-
require 'async/io/ssl_endpoint'
|
33
|
-
|
14
|
+
require 'async/http/client'
|
34
15
|
require 'samovar'
|
35
16
|
|
36
|
-
require 'rack/builder'
|
37
|
-
|
38
|
-
require 'bundler'
|
39
|
-
|
40
17
|
module Falcon
|
41
18
|
module Command
|
42
19
|
# Implements the `falcon serve` command. Designed for *development*.
|
@@ -67,6 +44,42 @@ module Falcon
|
|
67
44
|
option '--threads <count>', "Number of threads (hybrid only).", type: Integer
|
68
45
|
end
|
69
46
|
|
47
|
+
def container_options
|
48
|
+
@options.slice(:count, :forks, :threads)
|
49
|
+
end
|
50
|
+
|
51
|
+
def endpoint_options
|
52
|
+
@options.slice(:hostname, :port, :timeout)
|
53
|
+
end
|
54
|
+
|
55
|
+
def environment
|
56
|
+
Async::Service::Environment.new(Falcon::Environment::Server).with(
|
57
|
+
Falcon::Environment::Rackup,
|
58
|
+
|
59
|
+
root: Dir.pwd,
|
60
|
+
|
61
|
+
verbose: self.parent&.verbose?,
|
62
|
+
cache: @options[:cache],
|
63
|
+
|
64
|
+
container_options: self.container_options,
|
65
|
+
endpoint_options: self.endpoint_options,
|
66
|
+
|
67
|
+
rackup_path: @options[:config],
|
68
|
+
preload: [@options[:preload]].compact,
|
69
|
+
url: @options[:bind],
|
70
|
+
|
71
|
+
name: "server",
|
72
|
+
|
73
|
+
endpoint: ->{Endpoint.parse(url, **endpoint_options)}
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
def configuration
|
78
|
+
Configuration.new.tap do |configuration|
|
79
|
+
configuration.add(self.environment)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
70
83
|
# The container class to use.
|
71
84
|
def container_class
|
72
85
|
case @options[:container]
|
@@ -79,37 +92,6 @@ module Falcon
|
|
79
92
|
end
|
80
93
|
end
|
81
94
|
|
82
|
-
# Whether verbose logging is enabled.
|
83
|
-
# @returns [Boolean]
|
84
|
-
def verbose?
|
85
|
-
@parent&.verbose?
|
86
|
-
end
|
87
|
-
|
88
|
-
# Whether to enable the application HTTP cache.
|
89
|
-
# @returns [Boolean]
|
90
|
-
def cache?
|
91
|
-
@options[:cache]
|
92
|
-
end
|
93
|
-
|
94
|
-
# Load the rack application from the specified configuration path.
|
95
|
-
# @returns [Protocol::HTTP::Middleware]
|
96
|
-
def load_app
|
97
|
-
rack_app, _ = Rack::Builder.parse_file(@options[:config])
|
98
|
-
|
99
|
-
return Server.middleware(rack_app, verbose: self.verbose?, cache: self.cache?)
|
100
|
-
end
|
101
|
-
|
102
|
-
# Options for the container.
|
103
|
-
# See {Controller::Serve#setup}.
|
104
|
-
def container_options
|
105
|
-
@options.slice(:count, :forks, :threads)
|
106
|
-
end
|
107
|
-
|
108
|
-
# Options for the {endpoint}.
|
109
|
-
def endpoint_options
|
110
|
-
@options.slice(:hostname, :port, :reuse_port, :timeout)
|
111
|
-
end
|
112
|
-
|
113
95
|
# The endpoint to bind to.
|
114
96
|
def endpoint
|
115
97
|
Endpoint.parse(@options[:bind], **endpoint_options)
|
@@ -125,11 +107,6 @@ module Falcon
|
|
125
107
|
Async::HTTP::Client.new(client_endpoint)
|
126
108
|
end
|
127
109
|
|
128
|
-
# Prepare a new controller for the command.
|
129
|
-
def controller
|
130
|
-
Controller::Serve.new(self)
|
131
|
-
end
|
132
|
-
|
133
110
|
# Prepare the environment and run the controller.
|
134
111
|
def call
|
135
112
|
Console.logger.info(self) do |buffer|
|
@@ -139,22 +116,7 @@ module Falcon
|
|
139
116
|
buffer.puts "- To reload configuration: kill -HUP #{Process.pid}"
|
140
117
|
end
|
141
118
|
|
142
|
-
|
143
|
-
full_path = File.expand_path(path)
|
144
|
-
load(full_path)
|
145
|
-
end
|
146
|
-
|
147
|
-
begin
|
148
|
-
Bundler.require(:preload)
|
149
|
-
rescue Bundler::GemfileNotFound
|
150
|
-
# Ignore.
|
151
|
-
end
|
152
|
-
|
153
|
-
if GC.respond_to?(:compact)
|
154
|
-
GC.compact
|
155
|
-
end
|
156
|
-
|
157
|
-
self.controller.run
|
119
|
+
Async::Service::Controller.run(self.configuration, container_class: self.container_class)
|
158
120
|
end
|
159
121
|
end
|
160
122
|
end
|
@@ -1,24 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2019-2023, by Samuel Williams.
|
22
5
|
|
23
6
|
require 'samovar'
|
24
7
|
require 'async'
|
data/lib/falcon/command/top.rb
CHANGED
@@ -1,24 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2020-2024, by Samuel Williams.
|
22
5
|
|
23
6
|
require_relative 'serve'
|
24
7
|
require_relative 'host'
|
@@ -1,26 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
22
5
|
|
23
|
-
require_relative '../
|
6
|
+
require_relative '../service/virtual'
|
24
7
|
require_relative 'paths'
|
25
8
|
|
26
9
|
require 'samovar'
|
@@ -47,26 +30,20 @@ module Falcon
|
|
47
30
|
# @attribute [Array(String)]
|
48
31
|
many :paths
|
49
32
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
def bind_secure
|
59
|
-
@options[:bind_secure]
|
33
|
+
def environment
|
34
|
+
Async::Service::Environment.new(Falcon::Service::Virtual::Environment).with(
|
35
|
+
verbose: self.parent&.verbose?,
|
36
|
+
configuration_paths: self.paths,
|
37
|
+
bind_insecure: @options[:bind_insecure],
|
38
|
+
bind_secure: @options[:bind_secure],
|
39
|
+
timeout: @options[:timeout],
|
40
|
+
)
|
60
41
|
end
|
61
42
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
# The connection timeout to use for incoming connections.
|
68
|
-
def timeout
|
69
|
-
@options[:timeout]
|
43
|
+
def configuration
|
44
|
+
Async::Service::Configuration.new.tap do |configuration|
|
45
|
+
configuration.add(self.environment)
|
46
|
+
end
|
70
47
|
end
|
71
48
|
|
72
49
|
# Prepare the environment and run the controller.
|
@@ -77,9 +54,7 @@ module Falcon
|
|
77
54
|
buffer.puts "- To reload all sites: kill -HUP #{Process.pid}"
|
78
55
|
end
|
79
56
|
|
80
|
-
|
81
|
-
|
82
|
-
self.controller.run
|
57
|
+
Async::Service::Controller.run(self.configuration)
|
83
58
|
end
|
84
59
|
|
85
60
|
# The insecure endpoint for connecting to the {Redirect} instance.
|
data/lib/falcon/command.rb
CHANGED
@@ -1,24 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2017-2023, by Samuel Williams.
|
5
|
+
# Copyright, 2018, by Mitsutaka Mimura.
|
22
6
|
|
23
7
|
require_relative 'command/top'
|
24
8
|
|