spring 4.4.1 → 4.5.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
- data/README.md +2 -1
- data/lib/spring/application.rb +40 -5
- data/lib/spring/application_manager.rb +1 -1
- data/lib/spring/client/binstub.rb +1 -1
- data/lib/spring/client/run.rb +3 -1
- data/lib/spring/configuration.rb +8 -0
- data/lib/spring/server.rb +2 -0
- data/lib/spring/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 56e90e978202520c21d08823b1c539949f413ea8694868caec30042ede704533
|
|
4
|
+
data.tar.gz: 34d0bf24260d460621ba8dfbb5be7f3750a3c3b0e4c20092878f38aa66aee1a4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b367e099835ce1cca3769b616905ac31a3d2a3ae7271b93031ebeb5cb95711735db2f3bc952541e0609197f0dc98fe3c03b0df36210fa6645ae5ff28a83c90a6
|
|
7
|
+
data.tar.gz: 9c428924ba4c30c0cc5ee22e21da828b237ab686fee3d134519b16198127c3829288147b4eb056f3596c05efa46db2b7c3693f4e9a1a9c7bb362b7c020b34610
|
data/README.md
CHANGED
|
@@ -334,7 +334,8 @@ server process is started, it can be used to add new top-level commands.
|
|
|
334
334
|
Spring must know how to find your Rails application. If you have a
|
|
335
335
|
normal app everything works out of the box. If you are working on a
|
|
336
336
|
project with a special setup (an engine for example), you must tell
|
|
337
|
-
Spring where your app is located
|
|
337
|
+
Spring where your app is located by specifying the below code in a
|
|
338
|
+
`config/spring.rb` file relative to your engines root directory :
|
|
338
339
|
|
|
339
340
|
```ruby
|
|
340
341
|
Spring.application_root = './test/dummy'
|
data/lib/spring/application.rb
CHANGED
|
@@ -116,6 +116,9 @@ module Spring
|
|
|
116
116
|
|
|
117
117
|
require Spring.application_root_path.join("config", "environment")
|
|
118
118
|
|
|
119
|
+
invoke_after_environment_load_callbacks
|
|
120
|
+
preload_framework_base_classes
|
|
121
|
+
|
|
119
122
|
disconnect_database
|
|
120
123
|
|
|
121
124
|
@preloaded = :success
|
|
@@ -142,6 +145,19 @@ module Spring
|
|
|
142
145
|
end
|
|
143
146
|
end
|
|
144
147
|
|
|
148
|
+
# Eagerly autoload framework base classes
|
|
149
|
+
FRAMEWORK_BASE_CLASSES = %w[
|
|
150
|
+
ActionMailer::Base
|
|
151
|
+
ActionController::Base
|
|
152
|
+
ActionController::API
|
|
153
|
+
].freeze
|
|
154
|
+
|
|
155
|
+
def preload_framework_base_classes
|
|
156
|
+
FRAMEWORK_BASE_CLASSES.each do |const|
|
|
157
|
+
Object.const_get(const) if Object.const_defined?(const)
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
145
161
|
def eager_preload
|
|
146
162
|
with_pty do
|
|
147
163
|
# we can't see stderr and there could be issues when it's overflown
|
|
@@ -183,7 +199,7 @@ module Spring
|
|
|
183
199
|
client.puts(0) # preload success
|
|
184
200
|
rescue Exception
|
|
185
201
|
log "preload failed"
|
|
186
|
-
client.puts(1) # preload failure
|
|
202
|
+
ignore_client_disconnect { client.puts(1) } # preload failure
|
|
187
203
|
raise
|
|
188
204
|
end
|
|
189
205
|
end
|
|
@@ -244,15 +260,19 @@ module Spring
|
|
|
244
260
|
|
|
245
261
|
wait pid, streams, client
|
|
246
262
|
rescue Exception => e
|
|
247
|
-
|
|
263
|
+
if e.is_a?(Errno::EPIPE)
|
|
264
|
+
log "client disconnected (#{e.message}), ignoring command"
|
|
265
|
+
else
|
|
266
|
+
log "exception: #{e}"
|
|
267
|
+
end
|
|
248
268
|
manager.puts unless pid
|
|
249
269
|
|
|
250
270
|
if streams && !e.is_a?(SystemExit)
|
|
251
|
-
print_exception(stderr, e)
|
|
252
|
-
streams.each
|
|
271
|
+
ignore_client_disconnect { print_exception(stderr, e) }
|
|
272
|
+
streams.each { |stream| ignore_client_disconnect { stream.close } }
|
|
253
273
|
end
|
|
254
274
|
|
|
255
|
-
client.puts(1) if pid
|
|
275
|
+
ignore_client_disconnect { client.puts(1) if pid }
|
|
256
276
|
client.close
|
|
257
277
|
ensure
|
|
258
278
|
# Redirect STDOUT and STDERR to prevent from keeping the original FDs
|
|
@@ -300,6 +320,12 @@ module Spring
|
|
|
300
320
|
end
|
|
301
321
|
end
|
|
302
322
|
|
|
323
|
+
def invoke_after_environment_load_callbacks
|
|
324
|
+
Spring.after_environment_load_callbacks.each do |callback|
|
|
325
|
+
callback.call
|
|
326
|
+
end
|
|
327
|
+
end
|
|
328
|
+
|
|
303
329
|
def loaded_application_features
|
|
304
330
|
root = Spring.application_root_path.to_s
|
|
305
331
|
$LOADED_FEATURES.select { |f| f.start_with?(root) }
|
|
@@ -403,6 +429,15 @@ module Spring
|
|
|
403
429
|
|
|
404
430
|
private
|
|
405
431
|
|
|
432
|
+
# Tolerate Errno::EPIPE on writes to the client socket. Once the client
|
|
433
|
+
# disconnects, every subsequent write to it raises — that's expected
|
|
434
|
+
# during `serve`'s status reporting; we'd be talking to a process
|
|
435
|
+
# that's gone.
|
|
436
|
+
def ignore_client_disconnect
|
|
437
|
+
yield
|
|
438
|
+
rescue Errno::EPIPE
|
|
439
|
+
end
|
|
440
|
+
|
|
406
441
|
def active_record_configured?
|
|
407
442
|
defined?(ActiveRecord::Base) && ActiveRecord::Base.configurations.any?
|
|
408
443
|
end
|
|
@@ -102,7 +102,7 @@ module Spring
|
|
|
102
102
|
"RACK_ENV" => app_env,
|
|
103
103
|
"SPRING_ORIGINAL_ENV" => JSON.dump(Spring::ORIGINAL_ENV),
|
|
104
104
|
"SPRING_PRELOAD" => preload ? "1" : "0",
|
|
105
|
-
"SPRING_SPAWN_ENV" => JSON.dump(spawn_env),
|
|
105
|
+
"SPRING_SPAWN_ENV" => JSON.dump(spawn_env.compact),
|
|
106
106
|
**spawn_env,
|
|
107
107
|
},
|
|
108
108
|
"ruby",
|
|
@@ -26,7 +26,7 @@ module Spring
|
|
|
26
26
|
if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"])
|
|
27
27
|
require "bundler"
|
|
28
28
|
|
|
29
|
-
Bundler.
|
|
29
|
+
Bundler.definition.requested_specs.find { |spec| spec.name == "spring" }&.tap do |spring|
|
|
30
30
|
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
|
|
31
31
|
gem "spring", spring.version
|
|
32
32
|
require "spring/binstub"
|
data/lib/spring/client/run.rb
CHANGED
data/lib/spring/configuration.rb
CHANGED
|
@@ -35,6 +35,14 @@ module Spring
|
|
|
35
35
|
after_fork_callbacks << block
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
def after_environment_load_callbacks
|
|
39
|
+
@after_environment_load_callbacks ||= []
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def after_environment_load(&block)
|
|
43
|
+
after_environment_load_callbacks << block
|
|
44
|
+
end
|
|
45
|
+
|
|
38
46
|
def spawn_on_env
|
|
39
47
|
@spawn_on_env ||= []
|
|
40
48
|
end
|
data/lib/spring/server.rb
CHANGED
data/lib/spring/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spring
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jon Leighton
|
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
71
71
|
- !ruby/object:Gem::Version
|
|
72
72
|
version: '0'
|
|
73
73
|
requirements: []
|
|
74
|
-
rubygems_version:
|
|
74
|
+
rubygems_version: 3.6.7
|
|
75
75
|
specification_version: 4
|
|
76
76
|
summary: Rails application preloader
|
|
77
77
|
test_files: []
|