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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf3b9b590f0a6bce1bf2b23dc01cd32884a8d992
4
- data.tar.gz: 6fd9d0cd5224af34ff7cec5b485140eba506463d
3
+ metadata.gz: d14dc08475fd37c9118d173aea5ec37900657430
4
+ data.tar.gz: d6fbda6c06dfe77c7bdaa27f6a5cc45019ca5266
5
5
  SHA512:
6
- metadata.gz: b6c32c4667c1cb86d499332953b78b6933bb5f34d527701e64f52ba00b5155ee89e1d78e552b9c3fec81d827fd5923dfc37ba00910df87f7d9ebca7a698a96e5
7
- data.tar.gz: 8aa47cb7a911eac35f9eb25db622bddcdc3df93ea1d0f947f160e2e564daff71a2485fa6f3346c66b1c7c813e28ffc2c206c00f248a7ae55cb6a0689e25a1bff
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
@@ -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
- TIMEOUT = 1
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
- @signal_queue = []
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
- pid = Process.spawn(gem_env, env.server_command, out: File::NULL)
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
- exit status.exitstatus if status
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 <<-ERROR
101
- There is a version mismatch between the spring client (#{env.version}) and the server (#{server_version}).
102
- Restarting to resolve.
103
- ERROR
104
-
105
- stop_server
106
- cold_run
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], [], [], TIMEOUT)
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"
@@ -110,7 +110,7 @@ module Spring
110
110
  end
111
111
 
112
112
  def server_command
113
- ENV["SPRING_SERVER_COMMAND"] || "spring _#{Spring::VERSION}_ server --background"
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.spring_config.sub('.rb', '_client.rb')}", <<-RUBY)
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
@@ -88,6 +88,10 @@ module Spring
88
88
  path "config/spring.rb"
89
89
  end
90
90
 
91
+ def spring_client_config
92
+ path "config/spring_client.rb"
93
+ end
94
+
91
95
  def run(command, opts = {})
92
96
  start_time = Time.now
93
97
 
@@ -1,3 +1,3 @@
1
1
  module Spring
2
- VERSION = "1.7.0"
2
+ VERSION = "1.7.1"
3
3
  end
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.0
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-10 00:00:00.000000000 Z
11
+ date: 2016-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport