spring 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/lib/spring/client/run.rb +35 -12
- data/lib/spring/env.rb +1 -1
- data/lib/spring/test/acceptance_test.rb +10 -1
- data/lib/spring/test/application.rb +4 -0
- data/lib/spring/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d14dc08475fd37c9118d173aea5ec37900657430
|
4
|
+
data.tar.gz: d6fbda6c06dfe77c7bdaa27f6a5cc45019ca5266
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb7c61300a47f81d7ca46c5bf6bb50f679c665bb076b7d05fcacf923d8dc06a8b03b85313ea3f1f465e83fedb4f9ff38641270f9185439156261b03232a58201
|
7
|
+
data.tar.gz: e5bf9351f6bd9af0150cd0cdba8a04b556445a5cf485e69d89d2b6c3007cd91800a9f19c45732cae1e315805153cbab18911f6191d3c7508efc74c516170ad55
|
data/README.md
CHANGED
@@ -290,6 +290,13 @@ false
|
|
290
290
|
So to avoid this problem, don't save off references to application
|
291
291
|
constants in your initialization code.
|
292
292
|
|
293
|
+
## Using Spring with a containerized development environment
|
294
|
+
|
295
|
+
As of Spring 1.7, there is some support for doing this. See [this
|
296
|
+
example
|
297
|
+
repository](https://github.com/jonleighton/spring-docker-example) for
|
298
|
+
information about how to do it with [Docker](https://www.docker.com/).
|
299
|
+
|
293
300
|
## Configuration
|
294
301
|
|
295
302
|
Spring will read `~/.spring.rb` and `config/spring.rb` for custom
|
data/lib/spring/client/run.rb
CHANGED
@@ -6,13 +6,16 @@ module Spring
|
|
6
6
|
module Client
|
7
7
|
class Run < Command
|
8
8
|
FORWARDED_SIGNALS = %w(INT QUIT USR1 USR2 INFO WINCH) & Signal.list.keys
|
9
|
-
|
9
|
+
CONNECT_TIMEOUT = 1
|
10
|
+
BOOT_TIMEOUT = 10
|
10
11
|
|
11
12
|
attr_reader :server
|
12
13
|
|
13
14
|
def initialize(args)
|
14
15
|
super
|
15
|
-
|
16
|
+
|
17
|
+
@signal_queue = []
|
18
|
+
@server_booted = false
|
16
19
|
end
|
17
20
|
|
18
21
|
def log(message)
|
@@ -69,15 +72,31 @@ module Spring
|
|
69
72
|
|
70
73
|
def boot_server
|
71
74
|
env.socket_path.unlink if env.socket_path.exist?
|
72
|
-
|
75
|
+
|
76
|
+
pid = Process.spawn(gem_env, env.server_command, out: File::NULL)
|
77
|
+
timeout = Time.now + BOOT_TIMEOUT
|
78
|
+
|
79
|
+
@server_booted = true
|
73
80
|
|
74
81
|
until env.socket_path.exist?
|
75
82
|
_, status = Process.waitpid2(pid, Process::WNOHANG)
|
76
|
-
|
83
|
+
|
84
|
+
if status
|
85
|
+
exit status.exitstatus
|
86
|
+
elsif Time.now > timeout
|
87
|
+
$stderr.puts "Starting Spring server with `#{env.server_command}` " \
|
88
|
+
"timed out after #{BOOT_TIMEOUT} seconds"
|
89
|
+
exit 1
|
90
|
+
end
|
91
|
+
|
77
92
|
sleep 0.1
|
78
93
|
end
|
79
94
|
end
|
80
95
|
|
96
|
+
def server_booted?
|
97
|
+
@server_booted
|
98
|
+
end
|
99
|
+
|
81
100
|
def gem_env
|
82
101
|
bundle = Bundler.bundle_path.to_s
|
83
102
|
paths = Gem.path + ENV["GEM_PATH"].to_s.split(File::PATH_SEPARATOR)
|
@@ -97,13 +116,17 @@ module Spring
|
|
97
116
|
def verify_server_version
|
98
117
|
server_version = server.gets.chomp
|
99
118
|
if server_version != env.version
|
100
|
-
$stderr.puts
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
119
|
+
$stderr.puts "There is a version mismatch between the spring client " \
|
120
|
+
"(#{env.version}) and the server (#{server_version})."
|
121
|
+
|
122
|
+
if server_booted?
|
123
|
+
$stderr.puts "We already tried to reboot the server, but the mismatch is still present."
|
124
|
+
exit 1
|
125
|
+
else
|
126
|
+
$stderr.puts "Restarting to resolve."
|
127
|
+
stop_server
|
128
|
+
cold_run
|
129
|
+
end
|
107
130
|
end
|
108
131
|
end
|
109
132
|
|
@@ -111,7 +134,7 @@ ERROR
|
|
111
134
|
server.send_io client
|
112
135
|
send_json server, "args" => args, "default_rails_env" => default_rails_env
|
113
136
|
|
114
|
-
if IO.select([server], [], [],
|
137
|
+
if IO.select([server], [], [], CONNECT_TIMEOUT)
|
115
138
|
server.gets or raise CommandNotFound
|
116
139
|
else
|
117
140
|
raise "Error connecting to Spring server"
|
data/lib/spring/env.rb
CHANGED
@@ -110,7 +110,7 @@ module Spring
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def server_command
|
113
|
-
ENV["SPRING_SERVER_COMMAND"] || "spring
|
113
|
+
ENV["SPRING_SERVER_COMMAND"] || "#{File.expand_path("../../../bin/spring", __FILE__)} server --background"
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
@@ -404,7 +404,7 @@ module Spring
|
|
404
404
|
end
|
405
405
|
|
406
406
|
test "can define client tasks" do
|
407
|
-
File.write("#{app.
|
407
|
+
File.write("#{app.spring_client_config}", <<-RUBY)
|
408
408
|
Spring::Client::COMMANDS["foo"] = lambda { |args| puts "bar -- \#{args.inspect}" }
|
409
409
|
RUBY
|
410
410
|
assert_success "bin/spring foo --baz", stdout: "bar -- [\"foo\", \"--baz\"]\n"
|
@@ -525,6 +525,15 @@ module Spring
|
|
525
525
|
assert_success app.spring_test_command
|
526
526
|
end
|
527
527
|
end
|
528
|
+
|
529
|
+
test "server boot timeout" do
|
530
|
+
app.env["SPRING_SERVER_COMMAND"] = "sleep 1"
|
531
|
+
File.write("#{app.spring_client_config}", %(
|
532
|
+
Spring::Client::Run.const_set(:BOOT_TIMEOUT, 0.1)
|
533
|
+
))
|
534
|
+
|
535
|
+
assert_failure "bin/rails runner ''", stderr: "timed out"
|
536
|
+
end
|
528
537
|
end
|
529
538
|
end
|
530
539
|
end
|
data/lib/spring/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Leighton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|