spring 4.5.0 → 4.6.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 +25 -0
- data/lib/spring/application.rb +4 -0
- data/lib/spring/configuration.rb +6 -0
- data/lib/spring/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f386aff68c6b8feab1d79a933df930e6c47bf8d2f5f3610c7c483954e1b97cff
|
|
4
|
+
data.tar.gz: fb1ef130a243970266279570dad57c259ecd828cfab6b1043482ed429234e363
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: da2a3fbbb088ca721ed27128e0a60be6b8946b519ae4580fb7c99cc76f3052063b24bbacce932db0212a9308094e1e392e7a7c6937526dc19d940c896c4c4a1d
|
|
7
|
+
data.tar.gz: d712161465b1217b783046ec10ad2694c65bf7897ab78cc7e97d1b6c33ae0a124dc949f9dd056755d5aaf40890c502ee617e3ad2338cbe8551731ae8c29b1774
|
data/README.md
CHANGED
|
@@ -79,6 +79,31 @@ Spring manages. That setting is typically configured in
|
|
|
79
79
|
Note: in versions of Rails before 7.1, the setting is called `cache_classes`,
|
|
80
80
|
and it needs to be `false` for Spring to work.
|
|
81
81
|
|
|
82
|
+
#### Running Spring with reloading disabled (advanced, risky)
|
|
83
|
+
|
|
84
|
+
If you know what you are doing, and if every reloadable resource is configured
|
|
85
|
+
to materialize *lazily in the forked child*, not in the Spring server process,
|
|
86
|
+
then you can decide to run Spring without Rail's in-process reloaders.
|
|
87
|
+
|
|
88
|
+
To opt into this, set in `config/spring.rb`:
|
|
89
|
+
|
|
90
|
+
```ruby
|
|
91
|
+
Spring.dangerously_allow_disabling_reloading = true
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
If you set this, you should make sure that you are NOT pre-loading reloadable
|
|
95
|
+
resource in the Spring server. One approach is to add boot-time assertions at
|
|
96
|
+
the end of `Spring.after_environment_load`, e.g.:
|
|
97
|
+
|
|
98
|
+
```ruby
|
|
99
|
+
Spring.after_environment_load do
|
|
100
|
+
raise "routes were drawn at boot" if Rails.application.routes_reloader.loaded
|
|
101
|
+
raise "i18n locales where loaded at boot" unless I18n.backend.instance_variable_get(:@translations).nil?
|
|
102
|
+
end
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
When unsure, leave this disabled.
|
|
106
|
+
|
|
82
107
|
### Usage
|
|
83
108
|
|
|
84
109
|
For this walkthrough I've generated a new Rails application, and run
|
data/lib/spring/application.rb
CHANGED
|
@@ -101,6 +101,8 @@ module Spring
|
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
Rails::Application.initializer :ensure_reloading_is_enabled, group: :all do
|
|
104
|
+
next if Spring.dangerously_allow_disabling_reloading
|
|
105
|
+
|
|
104
106
|
if Rails.application.config.cache_classes
|
|
105
107
|
config_name, set_to = if Rails.application.config.respond_to?(:enable_reloading=)
|
|
106
108
|
["enable_reloading", "true"]
|
|
@@ -110,6 +112,8 @@ module Spring
|
|
|
110
112
|
raise <<-MSG.strip_heredoc
|
|
111
113
|
Spring reloads, and therefore needs the application to have reloading enabled.
|
|
112
114
|
Please, set config.#{config_name} to #{set_to} in config/environments/#{Rails.env}.rb.
|
|
115
|
+
(If you understand the trade-offs and want to disable Rails' reloader anyway,
|
|
116
|
+
set `Spring.dangerously_allow_disabling_reloading = true` in config/spring.rb.)
|
|
113
117
|
MSG
|
|
114
118
|
end
|
|
115
119
|
end
|
data/lib/spring/configuration.rb
CHANGED
|
@@ -3,11 +3,17 @@ require "spring/errors"
|
|
|
3
3
|
module Spring
|
|
4
4
|
@connect_timeout = 5
|
|
5
5
|
@boot_timeout = 20
|
|
6
|
+
@dangerously_allow_disabling_reloading = false
|
|
6
7
|
|
|
7
8
|
class << self
|
|
8
9
|
attr_accessor :application_root, :connect_timeout, :boot_timeout
|
|
9
10
|
attr_writer :quiet
|
|
10
11
|
|
|
12
|
+
# Opt-in: skip the `:ensure_reloading_is_enabled` initializer so Spring
|
|
13
|
+
# boots with `config.enable_reloading = false`. Default `false`. See
|
|
14
|
+
# README "Running Spring with reloading disabled" for what this gives up.
|
|
15
|
+
attr_accessor :dangerously_allow_disabling_reloading
|
|
16
|
+
|
|
11
17
|
def gemfile
|
|
12
18
|
require "bundler"
|
|
13
19
|
|
data/lib/spring/version.rb
CHANGED