falcon 0.52.4 → 0.53.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/lib/falcon/environment/server.rb +3 -23
- data/lib/falcon/service/server.rb +30 -50
- data/lib/falcon/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +4 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7a29bc2c8b56a674c1dd385f9655d454d0c792ee1c09c512cfc2019c265c3f17
|
|
4
|
+
data.tar.gz: 3a195cf6d478834756980f39ccc580d879b0b38a6272837aa51322dad8bd0cc4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7e9ec3a6e57f6768125efb73f99fbed1918f94665ba1635b89706fd5ca14ab074c4bcfa090f7dc290f2732142f27d94afff597a239ffcc36ce02b24278ff3a4f
|
|
7
|
+
data.tar.gz: e01aae910c60cb9bacf01949c784cedce9ecd4bd5b23c47544a0da0d347fce01a9394d9f0232abec1ed90e4f5de4a924bcf7d97c3ee81b4d569bb609292d3546
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Released under the MIT License.
|
|
4
4
|
# Copyright, 2020-2025, by Samuel Williams.
|
|
5
5
|
|
|
6
|
-
require "async/service/
|
|
6
|
+
require "async/service/managed_environment"
|
|
7
7
|
require "async/http/endpoint"
|
|
8
8
|
|
|
9
9
|
require_relative "../service/server"
|
|
@@ -13,6 +13,8 @@ module Falcon
|
|
|
13
13
|
module Environment
|
|
14
14
|
# Provides an environment for hosting a web application that uses a Falcon server.
|
|
15
15
|
module Server
|
|
16
|
+
include Async::Service::ManagedEnvironment
|
|
17
|
+
|
|
16
18
|
# The service class to use for the proxy.
|
|
17
19
|
# @returns [Class]
|
|
18
20
|
def service_class
|
|
@@ -25,21 +27,6 @@ module Falcon
|
|
|
25
27
|
self.name
|
|
26
28
|
end
|
|
27
29
|
|
|
28
|
-
# Number of instances to start. By default (when nil), uses `Etc.nprocessors`.
|
|
29
|
-
# @returns [Integer | nil]
|
|
30
|
-
def count
|
|
31
|
-
nil
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# Options to use when creating the container.
|
|
35
|
-
def container_options
|
|
36
|
-
{
|
|
37
|
-
restart: true,
|
|
38
|
-
count: self.count,
|
|
39
|
-
health_check_timeout: 30,
|
|
40
|
-
}.compact
|
|
41
|
-
end
|
|
42
|
-
|
|
43
30
|
# The host that this server will receive connections for.
|
|
44
31
|
def url
|
|
45
32
|
"http://[::]:9292"
|
|
@@ -80,13 +67,6 @@ module Falcon
|
|
|
80
67
|
::Async::HTTP::Endpoint.parse(url)
|
|
81
68
|
end
|
|
82
69
|
|
|
83
|
-
# Any scripts to preload before starting the server.
|
|
84
|
-
#
|
|
85
|
-
# @returns [Array(String)] The list of scripts to preload.
|
|
86
|
-
def preload
|
|
87
|
-
[]
|
|
88
|
-
end
|
|
89
|
-
|
|
90
70
|
# Make a server instance using the given endpoint. The endpoint may be a bound endpoint, so we take care to specify the protocol and scheme as per the original endpoint.
|
|
91
71
|
#
|
|
92
72
|
# @parameter endpoint [IO::Endpoint] The endpoint to bind to.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Copyright, 2019-2025, by Samuel Williams.
|
|
5
5
|
# Copyright, 2020, by Daniel Evans.
|
|
6
6
|
|
|
7
|
-
require "async/service/
|
|
7
|
+
require "async/service/managed_service"
|
|
8
8
|
require "async/container/supervisor/supervised"
|
|
9
9
|
require "async/http/endpoint"
|
|
10
10
|
|
|
@@ -12,28 +12,13 @@ require_relative "../server"
|
|
|
12
12
|
|
|
13
13
|
module Falcon
|
|
14
14
|
module Service
|
|
15
|
-
class Server < Async::Service::
|
|
15
|
+
class Server < Async::Service::ManagedService
|
|
16
16
|
def initialize(...)
|
|
17
17
|
super
|
|
18
18
|
|
|
19
19
|
@bound_endpoint = nil
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
# Preload any resources specified by the environment.
|
|
23
|
-
def preload!
|
|
24
|
-
root = @evaluator.root
|
|
25
|
-
|
|
26
|
-
if scripts = @evaluator.preload
|
|
27
|
-
scripts = Array(scripts)
|
|
28
|
-
|
|
29
|
-
scripts.each do |path|
|
|
30
|
-
Console.logger.info(self) {"Preloading #{path}..."}
|
|
31
|
-
full_path = File.expand_path(path, root)
|
|
32
|
-
load(full_path)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
22
|
# Prepare the bound endpoint for the server.
|
|
38
23
|
def start
|
|
39
24
|
@endpoint = @evaluator.endpoint
|
|
@@ -42,47 +27,42 @@ module Falcon
|
|
|
42
27
|
@bound_endpoint = @endpoint.bound
|
|
43
28
|
end
|
|
44
29
|
|
|
45
|
-
preload!
|
|
46
|
-
|
|
47
30
|
Console.logger.info(self) {"Starting #{self.name} on #{@endpoint}"}
|
|
48
31
|
|
|
49
32
|
super
|
|
50
33
|
end
|
|
51
34
|
|
|
52
|
-
#
|
|
53
|
-
#
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
35
|
+
# Run the service logic.
|
|
36
|
+
#
|
|
37
|
+
# @parameter instance [Object] The container instance.
|
|
38
|
+
# @parameter evaluator [Environment::Evaluator] The environment evaluator.
|
|
39
|
+
# @returns [Falcon::Server] The server instance.
|
|
40
|
+
def run(instance, evaluator)
|
|
41
|
+
if evaluator.key?(:make_supervised_worker)
|
|
42
|
+
Console.warn(self, "Async::Container::Supervisor is replaced by Async::Services::Supervisor, please update your service definition.")
|
|
43
|
+
|
|
44
|
+
evaluator.make_supervised_worker(instance).run
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
server = evaluator.make_server(@bound_endpoint)
|
|
57
48
|
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
Async do |task|
|
|
50
|
+
server.run
|
|
60
51
|
|
|
61
|
-
|
|
62
|
-
if @environment.implements?(Async::Container::Supervisor::Supervised)
|
|
63
|
-
evaluator.make_supervised_worker(instance).run
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
server = evaluator.make_server(@bound_endpoint)
|
|
67
|
-
|
|
68
|
-
server.run
|
|
69
|
-
|
|
70
|
-
instance.ready!
|
|
71
|
-
|
|
72
|
-
if health_check_timeout
|
|
73
|
-
Async(transient: true) do
|
|
74
|
-
while true
|
|
75
|
-
# We only update this if the health check is enabled. Maybe we should always update it?
|
|
76
|
-
instance.name = "#{self.name} (#{server.statistics_string} L=#{Fiber.scheduler.load.round(3)})"
|
|
77
|
-
sleep(health_check_timeout / 2)
|
|
78
|
-
instance.ready!
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
task.children.each(&:wait)
|
|
84
|
-
end
|
|
52
|
+
task.children.each(&:wait)
|
|
85
53
|
end
|
|
54
|
+
|
|
55
|
+
server
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Format the process title with server statistics.
|
|
59
|
+
#
|
|
60
|
+
# @parameter evaluator [Environment::Evaluator] The environment evaluator.
|
|
61
|
+
# @parameter server [Falcon::Server] The server instance.
|
|
62
|
+
# @returns [String] The formatted process title.
|
|
63
|
+
private def format_title(evaluator, server)
|
|
64
|
+
load = Fiber.scheduler.load.round(3)
|
|
65
|
+
"#{evaluator.name} (#{server.statistics_string} L=#{load})"
|
|
86
66
|
end
|
|
87
67
|
|
|
88
68
|
# Close the bound endpoint.
|
data/lib/falcon/version.rb
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: falcon
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.53.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -141,14 +141,14 @@ dependencies:
|
|
|
141
141
|
requirements:
|
|
142
142
|
- - "~>"
|
|
143
143
|
- !ruby/object:Gem::Version
|
|
144
|
-
version: '0.
|
|
144
|
+
version: '0.16'
|
|
145
145
|
type: :runtime
|
|
146
146
|
prerelease: false
|
|
147
147
|
version_requirements: !ruby/object:Gem::Requirement
|
|
148
148
|
requirements:
|
|
149
149
|
- - "~>"
|
|
150
150
|
- !ruby/object:Gem::Version
|
|
151
|
-
version: '0.
|
|
151
|
+
version: '0.16'
|
|
152
152
|
- !ruby/object:Gem::Dependency
|
|
153
153
|
name: bundler
|
|
154
154
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -312,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
312
312
|
- !ruby/object:Gem::Version
|
|
313
313
|
version: '0'
|
|
314
314
|
requirements: []
|
|
315
|
-
rubygems_version: 3.
|
|
315
|
+
rubygems_version: 3.6.9
|
|
316
316
|
specification_version: 4
|
|
317
317
|
summary: A fast, asynchronous, rack-compatible web server.
|
|
318
318
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|