spring 1.2.0 → 1.3.0

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: 0bae3c5f77134086e25e77df5d700895438e16ba
4
- data.tar.gz: 882c5139fed3fe573bb75136e683ca8ee3744069
3
+ metadata.gz: cf0643d72425f9cc14e93423dd4f131aa42b143a
4
+ data.tar.gz: 224eb7729ea0b874659a2951fea96fbdc3bb4c8a
5
5
  SHA512:
6
- metadata.gz: c5d7a1655a09f56c5663024af741c3c58fe9542418603a59dddb0c19ee24203a1527911a4626f6a5eedd5daf5b6e19b1107582fdc2c7528563af1878034cf1a7
7
- data.tar.gz: d143cad1d9b6f15440d80aa300b566a4fa19c0c90deada7fa627e3b230f9199ed56eae911c0005fa2ff83814bf3e66190777a42e0bb4cf5ee6d997df9d06b297
6
+ metadata.gz: f31525f82a8f8daa814e08ab0fb0ca65047fe25652037421899e7e4da566f7bbefb8b95bd4920fe40827d275b000e5f9dce5f1ea031c64bd807ebbe1912503e8
7
+ data.tar.gz: 07594958b366487e7b5f88d96edb3efa1b5f1378de5b68b37ef711d149084116cfd421562061e985c7d12a90d22a72caa8f96480362ca95eba40ed6916a3fa42
@@ -2,10 +2,11 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
- - 2.1.2
5
+ - 2.1.5
6
+ - 2.2.0
6
7
  env:
7
- - RAILS_VERSION="~> 3.2.0"
8
8
  - RAILS_VERSION="~> 4.0.0"
9
9
  - RAILS_VERSION="~> 4.1.0"
10
+ - RAILS_VERSION="~> 4.2.0"
10
11
  before_script:
11
12
  - travis_retry gem install rails --version "$RAILS_VERSION"
@@ -1,3 +1,20 @@
1
+ ## 1.3.0
2
+
3
+ * Automatically restart spring after new commands are added. This means
4
+ that you can add spring-commands-rspec to your Gemfile and then
5
+ immediately start using it, without having to run `spring stop`.
6
+ (Spring will effectively run `spring stop` for you.)
7
+ * Make app reloading work in apps which spew out lots of output on
8
+ startup (previously a buffer would fill up and cause the process to
9
+ hang). Issue #332.
10
+ * Make sure running `bin/spring` does not add an empty string to `Gem.path`.
11
+ Issues #297, #310.
12
+ * Fixed problem with `$0` including the command line args, which could
13
+ confuse commands which try to parse `$0`. This caused the
14
+ spring-commands-rspec to not work properly in some cases. Issue #369.
15
+ * Add OpenBSD compatibility for `spring status`. Issue #299.
16
+ * Rails 3.2 no longer officially supported (but it may continue to work)
17
+
1
18
  ## 1.2.0
2
19
 
3
20
  * Accept -e and --environment options for `rails console`.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Spring
2
2
 
3
- [![Build Status](https://travis-ci.org/rails/spring.png?branch=master)](https://travis-ci.org/rails/spring)
4
- [![Gem Version](https://badge.fury.io/rb/spring.png)](http://badge.fury.io/rb/spring)
3
+ [![Build Status](https://travis-ci.org/rails/spring.svg?branch=master)](https://travis-ci.org/rails/spring)
4
+ [![Gem Version](https://badge.fury.io/rb/spring.svg)](http://badge.fury.io/rb/spring)
5
5
 
6
6
  Spring is a Rails application preloader. It speeds up development by
7
7
  keeping your application running in the background so you don't need to
@@ -218,8 +218,7 @@ speed-up).
218
218
 
219
219
  ### Additional commands
220
220
 
221
- You can add these to your Gemfile for additional commands (run `spring stop` afterwards
222
- to pick up the changes):
221
+ You can add these to your Gemfile for additional commands:
223
222
 
224
223
  * [spring-commands-rspec](https://github.com/jonleighton/spring-commands-rspec)
225
224
  * [spring-commands-cucumber](https://github.com/jonleighton/spring-commands-cucumber)
@@ -158,7 +158,7 @@ module Spring
158
158
  trap("TERM", "DEFAULT")
159
159
 
160
160
  ARGV.replace(args)
161
- $0 = command.process_title
161
+ $0 = command.exec_name
162
162
 
163
163
  # Delete all env vars which are unchanged from before spring started
164
164
  original_env.each { |k, v| ENV.delete k if ENV[k] == v }
@@ -283,6 +283,7 @@ module Spring
283
283
  def with_pty
284
284
  PTY.open do |master, slave|
285
285
  [STDOUT, STDERR, STDIN].each { |s| s.reopen slave }
286
+ Thread.new { master.read }
286
287
  yield
287
288
  reset_streams
288
289
  end
@@ -38,7 +38,7 @@ unless defined?(Spring)
38
38
 
39
39
  if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)
40
40
  ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
41
- ENV["GEM_HOME"] = ""
41
+ ENV["GEM_HOME"] = nil
42
42
  Gem.paths = ENV
43
43
 
44
44
  gem "spring", match[1]
@@ -21,7 +21,37 @@ module Spring
21
21
  end
22
22
 
23
23
  def call
24
- boot_server unless env.server_running?
24
+ if env.server_running?
25
+ warm_run
26
+ else
27
+ cold_run
28
+ end
29
+ rescue Errno::ECONNRESET
30
+ exit 1
31
+ ensure
32
+ server.close if @server
33
+ end
34
+
35
+ def warm_run
36
+ run
37
+ rescue CommandNotFound
38
+ require "spring/commands"
39
+
40
+ if Spring.command?(args.first)
41
+ # Command installed since spring started
42
+ stop_server
43
+ cold_run
44
+ else
45
+ raise
46
+ end
47
+ end
48
+
49
+ def cold_run
50
+ boot_server
51
+ run
52
+ end
53
+
54
+ def run
25
55
  verify_server_version
26
56
 
27
57
  application, client = UNIXSocket.pair
@@ -29,19 +59,16 @@ module Spring
29
59
  queue_signals
30
60
  connect_to_application(client)
31
61
  run_command(client, application)
32
- rescue Errno::ECONNRESET
33
- exit 1
34
- ensure
35
- server.close if @server
36
62
  end
37
63
 
38
64
  def boot_server
39
65
  env.socket_path.unlink if env.socket_path.exist?
40
66
 
41
- pid = fork {
42
- require "spring/server"
43
- Spring::Server.boot
44
- }
67
+ pid = Process.spawn(
68
+ "ruby",
69
+ "-r", "spring/server",
70
+ "-e", "Spring::Server.boot"
71
+ )
45
72
 
46
73
  until env.socket_path.exist?
47
74
  _, status = Process.waitpid2(pid, Process::WNOHANG)
@@ -50,6 +77,12 @@ module Spring
50
77
  end
51
78
  end
52
79
 
80
+ def stop_server
81
+ server.close
82
+ @server = nil
83
+ env.stop
84
+ end
85
+
53
86
  def verify_server_version
54
87
  server_version = server.gets.chomp
55
88
  if server_version != env.version
@@ -17,11 +17,11 @@ module Spring
17
17
  end
18
18
 
19
19
  def print_process(pid)
20
- puts `ps -p #{pid} -o pid= -o args=`
20
+ puts `ps -p #{pid} -o pid= -o command=`
21
21
  end
22
22
 
23
23
  def application_pids
24
- candidates = `ps -A -o ppid= -o pid=`.lines
24
+ candidates = `ps -ax -o ppid= -o pid=`.lines
25
25
  candidates.select { |l| l =~ /^(\s+)?#{env.pid} / }
26
26
  .map { |l| l.split(" ").last }
27
27
  end
@@ -3,35 +3,20 @@ require "spring/version"
3
3
  module Spring
4
4
  module Client
5
5
  class Stop < Command
6
- TIMEOUT = 2 # seconds
7
-
8
6
  def self.description
9
7
  "Stop all spring processes for this project."
10
8
  end
11
9
 
12
10
  def call
13
- if env.server_running?
14
- timeout = Time.now + TIMEOUT
15
- kill 'TERM'
16
- sleep 0.1 until !env.server_running? || Time.now >= timeout
17
-
18
- if env.server_running?
19
- $stderr.puts "Spring did not stop; killing forcibly."
20
- kill 'KILL'
21
- else
22
- puts "Spring stopped."
23
- end
24
- else
11
+ case env.stop
12
+ when :stopped
13
+ puts "Spring stopped."
14
+ when :killed
15
+ $stderr.puts "Spring did not stop; killing forcibly."
16
+ when :not_running
25
17
  puts "Spring is not running"
26
18
  end
27
19
  end
28
-
29
- def kill(sig)
30
- pid = env.pid
31
- Process.kill(sig, pid) if pid
32
- rescue Errno::ESRCH
33
- # already dead
34
- end
35
20
  end
36
21
  end
37
22
  end
@@ -41,10 +41,6 @@ module Spring
41
41
  end
42
42
  end
43
43
 
44
- def process_title
45
- [name, *ARGV].join(" ")
46
- end
47
-
48
44
  def gem_name
49
45
  if command.respond_to?(:gem_name)
50
46
  command.gem_name
@@ -9,6 +9,7 @@ require "spring/configuration"
9
9
 
10
10
  module Spring
11
11
  IGNORE_SIGNALS = %w(INT QUIT)
12
+ STOP_TIMEOUT = 2 # seconds
12
13
 
13
14
  class Env
14
15
  attr_reader :log_file
@@ -80,5 +81,29 @@ module Spring
80
81
  log_file.puts "[#{Time.now}] [#{Process.pid}] #{message}"
81
82
  log_file.flush
82
83
  end
84
+
85
+ def stop
86
+ if server_running?
87
+ timeout = Time.now + STOP_TIMEOUT
88
+ kill 'TERM'
89
+ sleep 0.1 until !server_running? || Time.now >= timeout
90
+
91
+ if server_running?
92
+ kill 'KILL'
93
+ :killed
94
+ else
95
+ :stopped
96
+ end
97
+ else
98
+ :not_running
99
+ end
100
+ end
101
+
102
+ def kill(sig)
103
+ pid = self.pid
104
+ Process.kill(sig, pid) if pid
105
+ rescue Errno::ESRCH
106
+ # already dead
107
+ end
83
108
  end
84
109
  end
@@ -1,5 +1,8 @@
1
+ require "active_support"
1
2
  require "active_support/test_case"
2
3
 
4
+ ActiveSupport.test_order = :random
5
+
3
6
  module Spring
4
7
  module Test
5
8
  class << self
@@ -13,7 +13,7 @@ module Spring
13
13
  DEFAULT_SPEEDUP = 0.8
14
14
 
15
15
  def rails_version
16
- ENV['RAILS_VERSION'] || '~> 4.0.0'
16
+ ENV['RAILS_VERSION'] || '~> 4.2.0'
17
17
  end
18
18
 
19
19
  # Extension point for spring-watchers-listen
@@ -124,6 +124,16 @@ module Spring
124
124
  assert_failure app.spring_test_command, stdout: "RuntimeError: omg"
125
125
  end
126
126
 
127
+ test "app gets reloaded even with a ton of boot output" do
128
+ limit = UNIXSocket.pair.first.getsockopt(:SOCKET, :SNDBUF).int
129
+
130
+ assert_success app.spring_test_command
131
+ File.write(app.path("config/initializers/verbose.rb"), "#{limit}.times { puts 'x' }")
132
+
133
+ app.await_reload
134
+ assert_success app.spring_test_command
135
+ end
136
+
127
137
  test "app recovers when a boot-level error is introduced" do
128
138
  config = app.application_config.read
129
139
 
@@ -147,6 +157,9 @@ module Spring
147
157
  end
148
158
 
149
159
  test "custom commands" do
160
+ # Start spring before setting up the command, to test that it gracefully upgrades itself
161
+ assert_success "bin/rails runner ''"
162
+
150
163
  File.write(app.spring_config, <<-CODE)
151
164
  class CustomCommand
152
165
  def call
@@ -37,7 +37,7 @@ module Spring
37
37
 
38
38
  # Sporadic SSL errors keep causing test failures so there are anti-SSL workarounds here
39
39
  def generate_files
40
- system("gem list rails --installed --version '#{version_constraint}' || " \
40
+ system("gem list '^rails$' --installed --version '#{version_constraint}' || " \
41
41
  "gem install rails --clear-sources --source http://rubygems.org --version '#{version_constraint}'")
42
42
 
43
43
  @version = RailsVersion.new(`ruby -e 'puts Gem::Specification.find_by_name("rails", "#{version_constraint}").version'`.chomp)
@@ -1,3 +1,3 @@
1
1
  module Spring
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -18,6 +18,6 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_development_dependency 'activesupport'
21
+ gem.add_development_dependency 'activesupport', '~> 4.2.0'
22
22
  gem.add_development_dependency 'rake'
23
23
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spring
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.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: 2014-11-22 00:00:00.000000000 Z
11
+ date: 2015-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 4.2.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 4.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  requirements: []
121
121
  rubyforge_project:
122
- rubygems_version: 2.2.2
122
+ rubygems_version: 2.4.5
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Rails application preloader