spring 4.1.2 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spring/application/boot.rb +9 -3
- data/lib/spring/application.rb +5 -0
- data/lib/spring/application_manager.rb +6 -3
- data/lib/spring/client/run.rb +24 -3
- data/lib/spring/configuration.rb +8 -0
- data/lib/spring/server.rb +14 -5
- data/lib/spring/version.rb +1 -1
- data/lib/spring/watcher/abstract.rb +5 -0
- metadata +3 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76dbc0667df96e4ee560e9613dba5fbdf1dd1733eb93b4cfa8e9b9abe0ce4b88
|
4
|
+
data.tar.gz: 072b98f72493233f29ad64e034070ad4910807cd13d133772d29b1b1588e87ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 631a222c8b71faf7f115576537d857bd5e0d4824a9bdcc09ffcb694ef737af0af6570dfb112178efec1bbde9a1d5582bcfabfb1cd2ef8ea94b1404558580bd6d
|
7
|
+
data.tar.gz: c4d7ebbacf5c6b0a00263b96328e13160cfcea8033cb54ef4247d9aca3ee7f7c1f7d17a57865b10c24847c1653e99c61b37d2a8b130b45536aff994257944269
|
@@ -11,9 +11,15 @@ app = Spring::Application.new(
|
|
11
11
|
|
12
12
|
Signal.trap("TERM") { app.terminate }
|
13
13
|
|
14
|
-
Spring::ProcessTitleUpdater.run
|
15
|
-
|
16
|
-
|
14
|
+
Spring::ProcessTitleUpdater.run do |distance|
|
15
|
+
attributes = [
|
16
|
+
app.app_name,
|
17
|
+
"started #{distance} ago",
|
18
|
+
"#{app.app_env} mode",
|
19
|
+
app.spawn_env,
|
20
|
+
].compact
|
21
|
+
"spring app | #{attributes.join(" | ")}"
|
22
|
+
end
|
17
23
|
|
18
24
|
app.eager_preload if ENV.delete("SPRING_PRELOAD") == "1"
|
19
25
|
app.run
|
data/lib/spring/application.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module Spring
|
2
2
|
class ApplicationManager
|
3
|
-
attr_reader :pid, :child, :app_env, :spring_env, :status
|
3
|
+
attr_reader :pid, :child, :app_env, :spawn_env, :spring_env, :status
|
4
4
|
|
5
|
-
def initialize(app_env, spring_env)
|
5
|
+
def initialize(app_env, spawn_env, spring_env)
|
6
6
|
@app_env = app_env
|
7
|
+
@spawn_env = spawn_env
|
7
8
|
@spring_env = spring_env
|
8
9
|
@mutex = Mutex.new
|
9
10
|
@state = :running
|
@@ -100,7 +101,9 @@ module Spring
|
|
100
101
|
"RAILS_ENV" => app_env,
|
101
102
|
"RACK_ENV" => app_env,
|
102
103
|
"SPRING_ORIGINAL_ENV" => JSON.dump(Spring::ORIGINAL_ENV),
|
103
|
-
"SPRING_PRELOAD" => preload ? "1" : "0"
|
104
|
+
"SPRING_PRELOAD" => preload ? "1" : "0",
|
105
|
+
"SPRING_SPAWN_ENV" => JSON.dump(spawn_env),
|
106
|
+
**spawn_env,
|
104
107
|
},
|
105
108
|
"ruby",
|
106
109
|
*(bundler_dir != RbConfig::CONFIG["rubylibdir"] ? ["-I", bundler_dir] : []),
|
data/lib/spring/client/run.rb
CHANGED
@@ -73,7 +73,7 @@ module Spring
|
|
73
73
|
def boot_server
|
74
74
|
env.socket_path.unlink if env.socket_path.exist?
|
75
75
|
|
76
|
-
pid = Process.spawn(
|
76
|
+
pid = Process.spawn(server_process_env, env.server_command, out: File::NULL)
|
77
77
|
timeout = Time.now + BOOT_TIMEOUT
|
78
78
|
|
79
79
|
@server_booted = true
|
@@ -107,6 +107,14 @@ module Spring
|
|
107
107
|
}
|
108
108
|
end
|
109
109
|
|
110
|
+
def reset_env
|
111
|
+
ENV.slice(*Spring.reset_on_env)
|
112
|
+
end
|
113
|
+
|
114
|
+
def server_process_env
|
115
|
+
reset_env.merge(gem_env)
|
116
|
+
end
|
117
|
+
|
110
118
|
def stop_server
|
111
119
|
server.close
|
112
120
|
@server = nil
|
@@ -114,7 +122,16 @@ module Spring
|
|
114
122
|
end
|
115
123
|
|
116
124
|
def verify_server_version
|
117
|
-
|
125
|
+
unless IO.select([server], [], [], CONNECT_TIMEOUT)
|
126
|
+
raise "Error connecting to Spring server"
|
127
|
+
end
|
128
|
+
|
129
|
+
line = server.gets
|
130
|
+
unless line
|
131
|
+
raise "Error connecting to Spring server"
|
132
|
+
end
|
133
|
+
|
134
|
+
server_version = line.chomp
|
118
135
|
if server_version != env.version
|
119
136
|
$stderr.puts "There is a version mismatch between the Spring client " \
|
120
137
|
"(#{env.version}) and the server (#{server_version})."
|
@@ -132,7 +149,7 @@ module Spring
|
|
132
149
|
|
133
150
|
def connect_to_application(client)
|
134
151
|
server.send_io client
|
135
|
-
send_json server, "args" => args, "default_rails_env" => default_rails_env
|
152
|
+
send_json server, "args" => args, "default_rails_env" => default_rails_env, "spawn_env" => spawn_env, "reset_env" => reset_env
|
136
153
|
|
137
154
|
if IO.select([server], [], [], CONNECT_TIMEOUT)
|
138
155
|
server.gets or raise CommandNotFound
|
@@ -232,6 +249,10 @@ module Spring
|
|
232
249
|
def default_rails_env
|
233
250
|
ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
|
234
251
|
end
|
252
|
+
|
253
|
+
def spawn_env
|
254
|
+
ENV.slice(*Spring.spawn_on_env)
|
255
|
+
end
|
235
256
|
end
|
236
257
|
end
|
237
258
|
end
|
data/lib/spring/configuration.rb
CHANGED
data/lib/spring/server.rb
CHANGED
@@ -19,7 +19,9 @@ module Spring
|
|
19
19
|
def initialize(options = {})
|
20
20
|
@foreground = options.fetch(:foreground, false)
|
21
21
|
@env = options[:env] || default_env
|
22
|
-
@applications = Hash.new
|
22
|
+
@applications = Hash.new do |hash, key|
|
23
|
+
hash[key] = ApplicationManager.new(*key, env)
|
24
|
+
end
|
23
25
|
@pidfile = env.pidfile_path.open('a')
|
24
26
|
@mutex = Mutex.new
|
25
27
|
end
|
@@ -57,12 +59,15 @@ module Spring
|
|
57
59
|
app_client = client.recv_io
|
58
60
|
command = JSON.load(client.read(client.gets.to_i))
|
59
61
|
|
60
|
-
args, default_rails_env = command.values_at('args', 'default_rails_env')
|
62
|
+
args, default_rails_env, spawn_env, reset_env = command.values_at('args', 'default_rails_env', 'spawn_env', 'reset_env')
|
61
63
|
|
62
64
|
if Spring.command?(args.first)
|
65
|
+
application = @applications[rails_env_for(args, default_rails_env, spawn_env)]
|
66
|
+
reset_if_env_changed(application, reset_env)
|
67
|
+
|
63
68
|
log "running command #{args.first}"
|
64
69
|
client.puts
|
65
|
-
client.puts
|
70
|
+
client.puts application.run(app_client)
|
66
71
|
else
|
67
72
|
log "command not found #{args.first}"
|
68
73
|
client.close
|
@@ -73,8 +78,8 @@ module Spring
|
|
73
78
|
redirect_output
|
74
79
|
end
|
75
80
|
|
76
|
-
def rails_env_for(args, default_rails_env)
|
77
|
-
Spring.command(args.first).env(args.drop(1)) || default_rails_env
|
81
|
+
def rails_env_for(args, default_rails_env, spawn_env)
|
82
|
+
[Spring.command(args.first).env(args.drop(1)) || default_rails_env, spawn_env]
|
78
83
|
end
|
79
84
|
|
80
85
|
# Boot the server into the process group of the current session.
|
@@ -136,6 +141,10 @@ module Spring
|
|
136
141
|
|
137
142
|
private
|
138
143
|
|
144
|
+
def reset_if_env_changed(application, reset_env)
|
145
|
+
application.stop if ENV.slice(*reset_env.keys) != reset_env
|
146
|
+
end
|
147
|
+
|
139
148
|
def default_env
|
140
149
|
Env.new(log_file: default_log_file)
|
141
150
|
end
|
data/lib/spring/version.rb
CHANGED
metadata
CHANGED
@@ -1,57 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Leighton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rake
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bump
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: activesupport
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
11
|
+
date: 2024-04-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
55
13
|
description: Preloads your application so things like console, rake and tests run
|
56
14
|
faster
|
57
15
|
email:
|