pakyow-core 1.0.1 → 1.0.6
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
- data/CHANGELOG.md +114 -4
- data/lib/pakyow/actions/normalizer.rb +3 -3
- data/lib/pakyow/application.rb +5 -0
- data/lib/pakyow/application/behavior/aspects.rb +2 -2
- data/lib/pakyow/application/behavior/restarting.rb +7 -3
- data/lib/pakyow/application/connection.rb +13 -0
- data/lib/pakyow/behavior/restarting.rb +7 -5
- data/lib/pakyow/behavior/running.rb +6 -5
- data/lib/pakyow/cli.rb +3 -3
- data/lib/pakyow/connection.rb +10 -1
- data/lib/pakyow/environment.rb +38 -47
- data/lib/pakyow/generators/project.rb +1 -1
- data/lib/pakyow/logger/colorizer.rb +0 -2
- data/lib/pakyow/plugin.rb +4 -0
- data/lib/pakyow/process_manager.rb +14 -9
- data/lib/pakyow/rack/compatibility.rb +2 -2
- data/lib/pakyow/validator.rb +2 -2
- data/lib/pakyow/version.rb +7 -0
- metadata +23 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5bbd266fde598079a6a8a83a0cd72ca741b62d70a5b66d297d13d4f2c6107285
|
|
4
|
+
data.tar.gz: d6cc9b4d8473220a91ce9715844c113bb50586044cf4813a5e1fbbb50b06a085
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2aa195ed44ef3b1e99dd43ccefad981655accf1810adb0889af6fa598c877544c9219d5b9e98b51576c2c64ac393455ab78430adfe8bcefb122b579ae97d33bf
|
|
7
|
+
data.tar.gz: 55d7e4707016ee016245351408f348d5ebeebd1cb504cde441b6831263432f2770f9b399caa2633c2d533d140ee822bfe8fefcf65a5c05ed00648150848ac35d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,119 @@
|
|
|
1
|
-
#
|
|
1
|
+
# v1.0.4
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
* `fix` **Typecast header values to strings.**
|
|
4
|
+
- Resolves an incompatibility with `protocol-http`.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
*Related links:*
|
|
7
|
+
- [Pull Request #400][pr-400]
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
* `fix` **Bundler deprecation warnings (prefer `with_original_env`).**
|
|
10
|
+
|
|
11
|
+
*Related links:*
|
|
12
|
+
- [Commit a4bf384][a4bf384]
|
|
13
|
+
|
|
14
|
+
[pr-400]: https://github.com/pakyow/pakyow/pull/400
|
|
15
|
+
[a4bf384]: https://github.com/pakyow/pakyow/commit/a4bf384a4e8ee648a5b8780043b743f024331c64
|
|
16
|
+
|
|
17
|
+
# v1.0.3
|
|
18
|
+
|
|
19
|
+
* `fix` **Resolve several issues with respawns, restarts.**
|
|
20
|
+
|
|
21
|
+
*Related links:*
|
|
22
|
+
- [Pull Request #342][pr-342]
|
|
23
|
+
|
|
24
|
+
* `fix` **Ensure a logger and output is always available in the environment.**
|
|
25
|
+
|
|
26
|
+
*Related links:*
|
|
27
|
+
- [Pull Request #331][pr-331]
|
|
28
|
+
|
|
29
|
+
* `fix` **Start multiple processes when the process count specifies more than one.**
|
|
30
|
+
|
|
31
|
+
*Related links:*
|
|
32
|
+
- [Pull Request #329][pr-329]
|
|
33
|
+
|
|
34
|
+
* `fix` **Prevent failed processes from restarting indefinitely.**
|
|
35
|
+
|
|
36
|
+
*Related links:*
|
|
37
|
+
- [Pull Request #328][pr-328]
|
|
38
|
+
|
|
39
|
+
[pr-342]: https://github.com/pakyow/pakyow/pull/342
|
|
40
|
+
[pr-331]: https://github.com/pakyow/pakyow/pull/331
|
|
41
|
+
[pr-329]: https://github.com/pakyow/pakyow/pull/329
|
|
42
|
+
[pr-328]: https://github.com/pakyow/pakyow/pull/328
|
|
43
|
+
|
|
44
|
+
# v1.0.2
|
|
45
|
+
|
|
46
|
+
* `fix` **Relocate `version.rb` from the meta gem into `pakyow/core`.**
|
|
47
|
+
- Makes it possible to use `pakyow/core` and other gems without needing the meta gem.
|
|
48
|
+
|
|
49
|
+
*Related links:*
|
|
50
|
+
- [Pull Request #320][pr-320]
|
|
51
|
+
|
|
52
|
+
* `fix` **Query string missing from normalized uris.**
|
|
53
|
+
|
|
54
|
+
*Related links:*
|
|
55
|
+
- [Pull Request #315][pr-315]
|
|
56
|
+
|
|
57
|
+
* `fix` **Remove recursive require from `logger/colorizer.rb`.**
|
|
58
|
+
|
|
59
|
+
*Related links:*
|
|
60
|
+
- [Pull Request #311][pr-311]
|
|
61
|
+
|
|
62
|
+
* `fix` **Always load `config/application` relative to `Pakyow.config.root`.**
|
|
63
|
+
|
|
64
|
+
*Related links:*
|
|
65
|
+
- [Pull Request #310][pr-310]
|
|
66
|
+
|
|
67
|
+
* `fix` **Issue with `Pakyow::Error` not detecting gems in rvm.**
|
|
68
|
+
|
|
69
|
+
*Related links:*
|
|
70
|
+
- [Pull Request #306][pr-306]
|
|
71
|
+
|
|
72
|
+
* `fix` **Correct several issues with incorrect error backtraces, improve performance.**
|
|
73
|
+
|
|
74
|
+
*Related links:*
|
|
75
|
+
- [Commit cdb9e15][cdb9e15]
|
|
76
|
+
|
|
77
|
+
* `fix` **App connection path is relative to to the app mount path.**
|
|
78
|
+
|
|
79
|
+
*Related links:*
|
|
80
|
+
- [Commit fc6209f][fc6209f]
|
|
81
|
+
|
|
82
|
+
* `fix` **Backend aspects now load alphabetically on every system.**
|
|
83
|
+
|
|
84
|
+
*Related links:*
|
|
85
|
+
- [Commit 47189b7][47189b7]
|
|
86
|
+
|
|
87
|
+
* `fix` **Respawn into the correct environment by clearing `tmp/restart.txt`.**
|
|
88
|
+
|
|
89
|
+
*Related links:*
|
|
90
|
+
- [Commit c9d5544][c9d5544]
|
|
91
|
+
|
|
92
|
+
* `fix` **CLI short code arguments are now passed to the task in the correct order.**
|
|
93
|
+
|
|
94
|
+
*Related links:*
|
|
95
|
+
- [Commit 8604c1e][8604c1e]
|
|
96
|
+
|
|
97
|
+
[pr-320]: https://github.com/pakyow/pakyow/pull/320
|
|
98
|
+
[pr-315]: https://github.com/pakyow/pakyow/pull/315
|
|
99
|
+
[pr-311]: https://github.com/pakyow/pakyow/pull/311
|
|
100
|
+
[pr-310]: https://github.com/pakyow/pakyow/pull/310
|
|
101
|
+
[pr-306]: https://github.com/pakyow/pakyow/pull/306
|
|
102
|
+
[cdb9e15]: https://github.com/pakyow/pakyow/commit/cdb9e15f9840da4b5e909dc29b68c70ffa996a36
|
|
103
|
+
[fc6209f]: https://github.com/pakyow/pakyow/commit/fc6209fa12f1a0865cbd1a9c7c7f74e853a83a2a
|
|
104
|
+
[47189b7]: https://github.com/pakyow/pakyow/commit/47189b7d9fbb443f593f8e1573ddd6532ece9008
|
|
105
|
+
[c9d5544]: https://github.com/pakyow/pakyow/commit/cdb9e15f9840da4b5e909dc29b68c70ffa996a36
|
|
106
|
+
[8604c1e]: https://github.com/pakyow/pakyow/commit/8604c1e43a559acba9ab123586eb85d71df92691
|
|
107
|
+
|
|
108
|
+
# v1.0.1
|
|
109
|
+
|
|
110
|
+
* Rename `navigable` to `navigator` in the generated app.
|
|
111
|
+
|
|
112
|
+
*Related links:*
|
|
113
|
+
- [Commit bc7d9a3][bc7d9a3]
|
|
114
|
+
|
|
115
|
+
[bc7d9a3]: https://github.com/pakyow/pakyow/commit/bc7d9a39031a28e05c91a614d7e447ab061ede21
|
|
116
|
+
|
|
117
|
+
# v1.0.0
|
|
8
118
|
|
|
9
119
|
* Hello, Web
|
|
@@ -11,11 +11,11 @@ module Pakyow
|
|
|
11
11
|
|
|
12
12
|
def call(connection)
|
|
13
13
|
if strict_www? && require_www? && !www?(connection) && !subdomain?(connection)
|
|
14
|
-
redirect!(connection, File.join(add_www(connection), connection.
|
|
14
|
+
redirect!(connection, File.join(add_www(connection), connection.fullpath))
|
|
15
15
|
elsif strict_www? && !require_www? && www?(connection)
|
|
16
|
-
redirect!(connection, File.join(remove_www(connection), connection.
|
|
16
|
+
redirect!(connection, File.join(remove_www(connection), connection.fullpath))
|
|
17
17
|
elsif strict_path? && slash?(connection)
|
|
18
|
-
redirect!(connection, String.normalize_path(connection.
|
|
18
|
+
redirect!(connection, String.normalize_path(connection.fullpath))
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
data/lib/pakyow/application.rb
CHANGED
|
@@ -37,11 +37,11 @@ module Pakyow
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def __load_aspect(aspect, path: File.join(config.src, aspect.to_s), target: self.class)
|
|
40
|
-
Dir.glob(File.join(path, "*.rb")) do |file_path|
|
|
40
|
+
Dir.glob(File.join(path, "*.rb")).sort.each do |file_path|
|
|
41
41
|
Loader.new(file_path).call(target)
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
Dir.glob(File.join(path, "*")).select { |sub_path| File.directory?(sub_path) }.each do |directory|
|
|
44
|
+
Dir.glob(File.join(path, "*")).select { |sub_path| File.directory?(sub_path) }.sort.each do |directory|
|
|
45
45
|
__load_aspect(aspect, path: directory, target: target)
|
|
46
46
|
end
|
|
47
47
|
end
|
|
@@ -44,6 +44,11 @@ module Pakyow
|
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
+
def touch_restart
|
|
48
|
+
FileUtils.mkdir_p(File.join(config.root, "tmp"))
|
|
49
|
+
FileUtils.touch(File.join(config.root, "tmp/restart.txt"))
|
|
50
|
+
end
|
|
51
|
+
|
|
47
52
|
private
|
|
48
53
|
|
|
49
54
|
def setup_for_restarting
|
|
@@ -53,15 +58,14 @@ module Pakyow
|
|
|
53
58
|
|
|
54
59
|
# FIXME: this doesn't need to be hardcoded, but instead determined
|
|
55
60
|
# from the source location when registered with the environment
|
|
56
|
-
config.process.watched_paths << "
|
|
61
|
+
config.process.watched_paths << File.join(config.root, "config/application.rb")
|
|
57
62
|
|
|
58
63
|
Thread.new do
|
|
59
64
|
Filewatcher.new(
|
|
60
65
|
config.process.watched_paths,
|
|
61
66
|
exclude: config.process.excluded_paths
|
|
62
67
|
).watch do |_path, _event|
|
|
63
|
-
|
|
64
|
-
FileUtils.touch "./tmp/restart.txt"
|
|
68
|
+
touch_restart
|
|
65
69
|
end
|
|
66
70
|
end
|
|
67
71
|
end
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "delegate"
|
|
4
4
|
|
|
5
|
+
require "pakyow/support/core_refinements/string/normalization"
|
|
5
6
|
require "pakyow/support/hookable"
|
|
6
7
|
|
|
7
8
|
module Pakyow
|
|
@@ -20,6 +21,8 @@ module Pakyow
|
|
|
20
21
|
include Behavior::Verifier
|
|
21
22
|
include Behavior::Values
|
|
22
23
|
|
|
24
|
+
using Support::Refinements::String::Normalization
|
|
25
|
+
|
|
23
26
|
def initialize(app, connection)
|
|
24
27
|
performing :initialize do
|
|
25
28
|
@app = app; __setobj__(connection)
|
|
@@ -32,6 +35,16 @@ module Pakyow
|
|
|
32
35
|
end
|
|
33
36
|
end
|
|
34
37
|
|
|
38
|
+
def path
|
|
39
|
+
unless instance_variable_defined?(:@path)
|
|
40
|
+
@path = String.normalize_path(
|
|
41
|
+
__getobj__.path.split(@app.mount_path, 2)[1]
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
@path
|
|
46
|
+
end
|
|
47
|
+
|
|
35
48
|
def method
|
|
36
49
|
__getobj__.method
|
|
37
50
|
end
|
|
@@ -13,21 +13,21 @@ module Pakyow
|
|
|
13
13
|
|
|
14
14
|
# Other processes (e.g. apps) can touch this file to restart the server.
|
|
15
15
|
#
|
|
16
|
-
watch "
|
|
16
|
+
watch File.join(config.root, "tmp/restart.txt") do
|
|
17
17
|
restart
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
# Automatically bundle.
|
|
21
21
|
#
|
|
22
|
-
watch "
|
|
23
|
-
Bundler.
|
|
22
|
+
watch File.join(config.root, "Gemfile") do
|
|
23
|
+
Bundler.with_original_env do
|
|
24
24
|
Support::CLI::Runner.new(message: "Bundling").run("bundle install")
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
# Respawn when the bundle changes.
|
|
29
29
|
#
|
|
30
|
-
watch "
|
|
30
|
+
watch File.join(config.root, "Gemfile.lock") do
|
|
31
31
|
respawn
|
|
32
32
|
end
|
|
33
33
|
|
|
@@ -44,7 +44,9 @@ module Pakyow
|
|
|
44
44
|
# Set the respawn flag and stop the process manager.
|
|
45
45
|
# Pakyow will check the flag and respawn from the main thread.
|
|
46
46
|
#
|
|
47
|
-
@respawn = true
|
|
47
|
+
@respawn = true
|
|
48
|
+
@bound_endpoint.close
|
|
49
|
+
@process_manager.stop
|
|
48
50
|
end
|
|
49
51
|
end
|
|
50
52
|
end
|
|
@@ -16,7 +16,7 @@ module Pakyow
|
|
|
16
16
|
extend Support::Extension
|
|
17
17
|
|
|
18
18
|
apply_extension do
|
|
19
|
-
unfreezable :process_manager
|
|
19
|
+
unfreezable :process_manager, :bound_endpoint
|
|
20
20
|
|
|
21
21
|
class_state :processes, default: []
|
|
22
22
|
|
|
@@ -42,7 +42,7 @@ module Pakyow
|
|
|
42
42
|
"http://#{config.server.host}:#{port}"
|
|
43
43
|
)
|
|
44
44
|
|
|
45
|
-
bound_endpoint = Async::Reactor.run {
|
|
45
|
+
@bound_endpoint = Async::Reactor.run {
|
|
46
46
|
Async::IO::SharedEndpoint.bound(endpoint)
|
|
47
47
|
}.wait
|
|
48
48
|
|
|
@@ -52,7 +52,7 @@ module Pakyow
|
|
|
52
52
|
Processes::Server.new(
|
|
53
53
|
protocol: endpoint.protocol,
|
|
54
54
|
scheme: endpoint.scheme,
|
|
55
|
-
endpoint: bound_endpoint
|
|
55
|
+
endpoint: @bound_endpoint
|
|
56
56
|
).run
|
|
57
57
|
end
|
|
58
58
|
|
|
@@ -69,7 +69,7 @@ module Pakyow
|
|
|
69
69
|
@processes << {
|
|
70
70
|
name: name,
|
|
71
71
|
block: block,
|
|
72
|
-
count: count,
|
|
72
|
+
count: count.to_i,
|
|
73
73
|
restartable: restartable
|
|
74
74
|
}
|
|
75
75
|
end
|
|
@@ -100,7 +100,7 @@ module Pakyow
|
|
|
100
100
|
#
|
|
101
101
|
exec "PW_RESPAWN=true #{$0} #{ARGV.join(" ")}"
|
|
102
102
|
end
|
|
103
|
-
rescue SignalException
|
|
103
|
+
rescue SignalException, Interrupt
|
|
104
104
|
exit
|
|
105
105
|
end
|
|
106
106
|
|
|
@@ -114,6 +114,7 @@ module Pakyow
|
|
|
114
114
|
Pakyow.logger << "Goodbye"
|
|
115
115
|
|
|
116
116
|
performing :shutdown do
|
|
117
|
+
@bound_endpoint.close
|
|
117
118
|
@process_manager.stop
|
|
118
119
|
end
|
|
119
120
|
end
|
data/lib/pakyow/cli.rb
CHANGED
|
@@ -103,7 +103,7 @@ module Pakyow
|
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
def parse_with_unknown_args
|
|
106
|
-
parser,
|
|
106
|
+
parser, original, unparsed = yield, @argv.dup, Array.new
|
|
107
107
|
|
|
108
108
|
begin
|
|
109
109
|
parser.order!(@argv) do |arg|
|
|
@@ -114,10 +114,10 @@ module Pakyow
|
|
|
114
114
|
end
|
|
115
115
|
end
|
|
116
116
|
rescue OptionParser::InvalidOption => error
|
|
117
|
-
|
|
117
|
+
unparsed.concat(error.args); retry
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
-
@argv = (original &
|
|
120
|
+
@argv = (original & @argv) + unparsed
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
def setup_environment
|
data/lib/pakyow/connection.rb
CHANGED
|
@@ -82,7 +82,7 @@ module Pakyow
|
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
def set_header(key, value)
|
|
85
|
-
@headers[normalize_header(key)] = value
|
|
85
|
+
@headers[normalize_header(key)] = normalize_header_value(value)
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
def set_headers(headers)
|
|
@@ -370,6 +370,15 @@ module Pakyow
|
|
|
370
370
|
key.to_s.downcase.gsub("_", "-")
|
|
371
371
|
end
|
|
372
372
|
|
|
373
|
+
def normalize_header_value(value)
|
|
374
|
+
case value
|
|
375
|
+
when Array
|
|
376
|
+
value.map(&:to_s)
|
|
377
|
+
else
|
|
378
|
+
value.to_s
|
|
379
|
+
end
|
|
380
|
+
end
|
|
381
|
+
|
|
373
382
|
DELETE_COOKIE = {
|
|
374
383
|
value: nil, path: nil, domain: nil, max_age: 0, expires: Time.at(0)
|
|
375
384
|
}.freeze
|
data/lib/pakyow/environment.rb
CHANGED
|
@@ -33,6 +33,7 @@ require "pakyow/actions/normalizer"
|
|
|
33
33
|
|
|
34
34
|
require "pakyow/application"
|
|
35
35
|
|
|
36
|
+
require "pakyow/logger"
|
|
36
37
|
require "pakyow/logger/destination"
|
|
37
38
|
require "pakyow/logger/multiplexed"
|
|
38
39
|
require "pakyow/logger/thread_local"
|
|
@@ -135,17 +136,32 @@ module Pakyow
|
|
|
135
136
|
#
|
|
136
137
|
attr_reader :env
|
|
137
138
|
|
|
138
|
-
#
|
|
139
|
+
# Any error encountered during the boot process
|
|
139
140
|
#
|
|
140
|
-
attr_reader :
|
|
141
|
+
attr_reader :error
|
|
141
142
|
|
|
142
|
-
# Global
|
|
143
|
+
# Global log output.
|
|
144
|
+
#
|
|
145
|
+
# Builds and returns a default global output that's replaced in `setup`.
|
|
143
146
|
#
|
|
144
|
-
|
|
147
|
+
def global_logger
|
|
148
|
+
unless defined?(@global_logger)
|
|
149
|
+
require "pakyow/logger/formatters/human"
|
|
150
|
+
@global_logger = Logger::Formatters::Human.new(
|
|
151
|
+
Logger::Destination.new(:stdout, $stdout)
|
|
152
|
+
)
|
|
153
|
+
end
|
|
145
154
|
|
|
146
|
-
|
|
155
|
+
@global_logger
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Logger instance for the environment.
|
|
147
159
|
#
|
|
148
|
-
|
|
160
|
+
# Builds and returns a default logger that's replaced in `setup`.
|
|
161
|
+
#
|
|
162
|
+
def logger
|
|
163
|
+
@logger ||= Logger.new("dflt", output: global_logger, level: :all)
|
|
164
|
+
end
|
|
149
165
|
|
|
150
166
|
# Mounts an app at a path.
|
|
151
167
|
#
|
|
@@ -182,7 +198,7 @@ module Pakyow
|
|
|
182
198
|
# Loads apps located in the current project.
|
|
183
199
|
#
|
|
184
200
|
def load_apps
|
|
185
|
-
require "
|
|
201
|
+
require File.join(config.root, "config/application")
|
|
186
202
|
end
|
|
187
203
|
|
|
188
204
|
# Prepares the environment for booting.
|
|
@@ -200,20 +216,24 @@ module Pakyow
|
|
|
200
216
|
end
|
|
201
217
|
|
|
202
218
|
performing :setup do
|
|
203
|
-
|
|
219
|
+
destinations = Logger::Multiplexed.new(
|
|
220
|
+
*config.logger.destinations.map { |destination, io|
|
|
221
|
+
io.sync = config.logger.sync
|
|
222
|
+
Logger::Destination.new(destination, io)
|
|
223
|
+
}
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
@global_logger = config.logger.formatter.new(destinations)
|
|
227
|
+
|
|
228
|
+
@logger = Logger::ThreadLocal.new(
|
|
229
|
+
Logger.new("pkyw", output: @global_logger, level: config.logger.level)
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
Console.logger = Logger.new("asnc", output: @global_logger, level: :warn)
|
|
204
233
|
end
|
|
205
234
|
|
|
206
235
|
self
|
|
207
236
|
rescue => error
|
|
208
|
-
begin
|
|
209
|
-
# Try again to initialize the logger, since we may have failed before that point.
|
|
210
|
-
#
|
|
211
|
-
unless Pakyow.logger
|
|
212
|
-
init_global_logger
|
|
213
|
-
end
|
|
214
|
-
rescue
|
|
215
|
-
end
|
|
216
|
-
|
|
217
237
|
@setup_error = error; self
|
|
218
238
|
end
|
|
219
239
|
|
|
@@ -344,23 +364,6 @@ module Pakyow
|
|
|
344
364
|
|
|
345
365
|
private
|
|
346
366
|
|
|
347
|
-
def init_global_logger
|
|
348
|
-
destinations = Logger::Multiplexed.new(
|
|
349
|
-
*config.logger.destinations.map { |destination, io|
|
|
350
|
-
io.sync = config.logger.sync
|
|
351
|
-
Logger::Destination.new(destination, io)
|
|
352
|
-
}
|
|
353
|
-
)
|
|
354
|
-
|
|
355
|
-
@global_logger = config.logger.formatter.new(destinations)
|
|
356
|
-
|
|
357
|
-
@logger = Logger::ThreadLocal.new(
|
|
358
|
-
Logger.new("pkyw", output: @global_logger, level: config.logger.level)
|
|
359
|
-
)
|
|
360
|
-
|
|
361
|
-
Console.logger = Logger.new("asnc", output: @global_logger, level: :warn)
|
|
362
|
-
end
|
|
363
|
-
|
|
364
367
|
def ensure_setup_succeeded
|
|
365
368
|
if @setup_error
|
|
366
369
|
handle_boot_failure(@setup_error)
|
|
@@ -370,23 +373,11 @@ module Pakyow
|
|
|
370
373
|
def handle_boot_failure(error)
|
|
371
374
|
@error = error
|
|
372
375
|
|
|
373
|
-
|
|
374
|
-
if logger.respond_to?(:houston)
|
|
375
|
-
logger.houston(error)
|
|
376
|
-
else
|
|
377
|
-
logger.error(error)
|
|
378
|
-
end
|
|
379
|
-
end
|
|
376
|
+
logger.houston(error)
|
|
380
377
|
|
|
381
378
|
if config.exit_on_boot_failure
|
|
382
379
|
exit(false)
|
|
383
380
|
end
|
|
384
381
|
end
|
|
385
|
-
|
|
386
|
-
require "logger"
|
|
387
|
-
|
|
388
|
-
def safe_logger
|
|
389
|
-
yield logger || ::Logger.new($stdout)
|
|
390
|
-
end
|
|
391
382
|
end
|
|
392
383
|
end
|
data/lib/pakyow/plugin.rb
CHANGED
|
@@ -36,18 +36,23 @@ module Pakyow
|
|
|
36
36
|
private
|
|
37
37
|
|
|
38
38
|
def run_process(process)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Async
|
|
39
|
+
process[:count].times do
|
|
40
|
+
Fiber.new {
|
|
41
|
+
until @stopped
|
|
42
|
+
status = @group.fork(process) do
|
|
43
|
+
Async do
|
|
44
|
+
process[:block].call
|
|
45
|
+
rescue => error
|
|
46
|
+
Pakyow.logger.houston(error)
|
|
47
|
+
exit 1
|
|
48
|
+
end
|
|
44
49
|
rescue Interrupt
|
|
45
50
|
end
|
|
46
|
-
}
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
break unless status.success?
|
|
53
|
+
end
|
|
54
|
+
}.resume
|
|
55
|
+
end
|
|
51
56
|
end
|
|
52
57
|
end
|
|
53
58
|
end
|
|
@@ -21,7 +21,7 @@ module Pakyow
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def request_header(key)
|
|
24
|
-
|
|
24
|
+
normalize_header_key_value(key, @request.get_header(normalize_header(key)))
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def request_header?(key)
|
|
@@ -56,7 +56,7 @@ module Pakyow
|
|
|
56
56
|
key.to_s.upcase.gsub("-", "_")
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
def
|
|
59
|
+
def normalize_header_key_value(key, value)
|
|
60
60
|
if value && policy = Protocol::HTTP::Headers::MERGE_POLICY[key.to_s.downcase.gsub("_", "-")]
|
|
61
61
|
policy.new(value.to_s)
|
|
62
62
|
else
|
data/lib/pakyow/validator.rb
CHANGED
|
@@ -62,9 +62,9 @@ module Pakyow
|
|
|
62
62
|
@validations.any?
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
-
def validate(validation_name = nil, **options)
|
|
65
|
+
def validate(validation_name = nil, **options, &block)
|
|
66
66
|
validation_object = if block_given?
|
|
67
|
-
Validations::Inline.new(validation_name,
|
|
67
|
+
Validations::Inline.new(validation_name, block)
|
|
68
68
|
else
|
|
69
69
|
self.class.validation_object_for(validation_name)
|
|
70
70
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pakyow-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bryan Powell
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: commands
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-09-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: pakyow-support
|
|
@@ -16,56 +16,56 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - '='
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 1.0.
|
|
19
|
+
version: 1.0.6
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - '='
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 1.0.
|
|
26
|
+
version: 1.0.6
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: async
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '1.
|
|
33
|
+
version: '1.23'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '1.
|
|
40
|
+
version: '1.23'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: async-http
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 0.
|
|
47
|
+
version: 0.49.0
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 0.
|
|
54
|
+
version: 0.49.0
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: async-io
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '1.
|
|
61
|
+
version: '1.27'
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '1.
|
|
68
|
+
version: '1.27'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: bundler
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -86,28 +86,28 @@ dependencies:
|
|
|
86
86
|
requirements:
|
|
87
87
|
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '1.
|
|
89
|
+
version: '1.5'
|
|
90
90
|
type: :runtime
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '1.
|
|
96
|
+
version: '1.5'
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
98
|
name: dry-types
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
101
|
- - "~>"
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '1.
|
|
103
|
+
version: '1.2'
|
|
104
104
|
type: :runtime
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: '1.
|
|
110
|
+
version: '1.2'
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
112
|
name: filewatcher
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -128,14 +128,14 @@ dependencies:
|
|
|
128
128
|
requirements:
|
|
129
129
|
- - "~>"
|
|
130
130
|
- !ruby/object:Gem::Version
|
|
131
|
-
version:
|
|
131
|
+
version: 0.9.2
|
|
132
132
|
type: :runtime
|
|
133
133
|
prerelease: false
|
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
|
135
135
|
requirements:
|
|
136
136
|
- - "~>"
|
|
137
137
|
- !ruby/object:Gem::Version
|
|
138
|
-
version:
|
|
138
|
+
version: 0.9.2
|
|
139
139
|
- !ruby/object:Gem::Dependency
|
|
140
140
|
name: mini_mime
|
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -184,14 +184,14 @@ dependencies:
|
|
|
184
184
|
requirements:
|
|
185
185
|
- - "~>"
|
|
186
186
|
- !ruby/object:Gem::Version
|
|
187
|
-
version: '
|
|
187
|
+
version: '13.0'
|
|
188
188
|
type: :runtime
|
|
189
189
|
prerelease: false
|
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
|
191
191
|
requirements:
|
|
192
192
|
- - "~>"
|
|
193
193
|
- !ruby/object:Gem::Version
|
|
194
|
-
version: '
|
|
194
|
+
version: '13.0'
|
|
195
195
|
description: Core functionality for Pakyow
|
|
196
196
|
email: bryan@bryanp.org
|
|
197
197
|
executables:
|
|
@@ -317,11 +317,12 @@ files:
|
|
|
317
317
|
- lib/pakyow/validations/presence.rb
|
|
318
318
|
- lib/pakyow/validator.rb
|
|
319
319
|
- lib/pakyow/verifier.rb
|
|
320
|
+
- lib/pakyow/version.rb
|
|
320
321
|
homepage: https://pakyow.com
|
|
321
322
|
licenses:
|
|
322
323
|
- LGPL-3.0
|
|
323
324
|
metadata: {}
|
|
324
|
-
post_install_message:
|
|
325
|
+
post_install_message:
|
|
325
326
|
rdoc_options: []
|
|
326
327
|
require_paths:
|
|
327
328
|
- lib
|
|
@@ -336,8 +337,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
336
337
|
- !ruby/object:Gem::Version
|
|
337
338
|
version: '0'
|
|
338
339
|
requirements: []
|
|
339
|
-
rubygems_version: 3.
|
|
340
|
-
signing_key:
|
|
340
|
+
rubygems_version: 3.1.2
|
|
341
|
+
signing_key:
|
|
341
342
|
specification_version: 4
|
|
342
343
|
summary: Pakyow Core
|
|
343
344
|
test_files: []
|