spring 1.1.3 → 1.3.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/.gitignore +1 -0
- data/.travis.yml +3 -2
- data/CHANGELOG.md +26 -0
- data/CONTRIBUTING.md +5 -0
- data/Gemfile +0 -2
- data/README.md +22 -15
- data/Rakefile +1 -1
- data/lib/spring/application.rb +6 -1
- data/lib/spring/client/binstub.rb +2 -2
- data/lib/spring/client/run.rb +42 -9
- data/lib/spring/client/status.rb +2 -2
- data/lib/spring/client/stop.rb +6 -21
- data/lib/spring/command_wrapper.rb +0 -4
- data/lib/spring/commands/rails.rb +13 -1
- data/lib/spring/commands.rb +11 -2
- data/lib/spring/env.rb +27 -2
- data/lib/spring/sid.rb +1 -1
- data/lib/spring/test/acceptance_test.rb +346 -0
- data/{test/acceptance/helper.rb → lib/spring/test/application.rb} +1 -128
- data/lib/spring/test/application_generator.rb +121 -0
- data/lib/spring/test/rails_version.rb +40 -0
- data/lib/spring/test/watcher_test.rb +167 -0
- data/lib/spring/test.rb +18 -0
- data/lib/spring/version.rb +1 -1
- data/lib/spring/watcher/polling.rb +2 -0
- data/lib/spring/watcher.rb +4 -8
- data/spring.gemspec +1 -1
- data/test/acceptance_test.rb +4 -0
- data/test/helper.rb +2 -2
- data/test/unit/commands_test.rb +11 -1
- data/test/unit/watcher_test.rb +2 -188
- metadata +15 -12
- data/lib/spring/watcher/listen.rb +0 -52
- data/test/acceptance/app_test.rb +0 -334
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cf0643d72425f9cc14e93423dd4f131aa42b143a
|
|
4
|
+
data.tar.gz: 224eb7729ea0b874659a2951fea96fbdc3bb4c8a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f31525f82a8f8daa814e08ab0fb0ca65047fe25652037421899e7e4da566f7bbefb8b95bd4920fe40827d275b000e5f9dce5f1ea031c64bd807ebbe1912503e8
|
|
7
|
+
data.tar.gz: 07594958b366487e7b5f88d96edb3efa1b5f1378de5b68b37ef711d149084116cfd421562061e985c7d12a90d22a72caa8f96480362ca95eba40ed6916a3fa42
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
|
@@ -2,10 +2,11 @@ language: ruby
|
|
|
2
2
|
rvm:
|
|
3
3
|
- 1.9.3
|
|
4
4
|
- 2.0.0
|
|
5
|
-
- 2.1.
|
|
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"
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
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
|
+
|
|
18
|
+
## 1.2.0
|
|
19
|
+
|
|
20
|
+
* Accept -e and --environment options for `rails console`.
|
|
21
|
+
* Watch `config/secrets.yml` by default. #289 - @morgoth
|
|
22
|
+
* Change monkey-patched `Kernel.raise` from public to private (to match default Ruby behavior) #351 - @mattbrictson
|
|
23
|
+
* Let application_id also respect RUBY_VERSION for the use case of switching between Ruby versions for a given Rails app - @methodmissing
|
|
24
|
+
* Extract the 'listen' watcher to a separate `spring-watcher-listen`
|
|
25
|
+
gem. This allows it to be developed/maintained separately.
|
|
26
|
+
|
|
1
27
|
## 1.1.3
|
|
2
28
|
|
|
3
29
|
* The `rails runner` command no longer passes environment switches to
|
data/CONTRIBUTING.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
# Spring
|
|
2
2
|
|
|
3
|
-
[](https://travis-ci.org/rails/spring)
|
|
4
|
+
[](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
|
|
8
8
|
boot it every time you run a test, rake task or migration.
|
|
9
9
|
|
|
10
|
-
**Upgrading to 1.1? It's recommended to run `bundle exec spring binstub --all` to regenerate your binstubs.**
|
|
11
|
-
|
|
12
10
|
## Features
|
|
13
11
|
|
|
14
12
|
* Totally automatic; no need to explicitly start and stop the background process
|
|
@@ -61,8 +59,10 @@ will just be silently ignored and the lines after it will be executed as
|
|
|
61
59
|
normal.
|
|
62
60
|
|
|
63
61
|
If you don't want to prefix every command you type with `bin/`, you
|
|
64
|
-
can [use direnv](https://github.com/zimbatm/direnv) to
|
|
65
|
-
`./bin` to your `PATH` when you `cd` into your application.
|
|
62
|
+
can [use direnv](https://github.com/zimbatm/direnv#the-stdlib) to
|
|
63
|
+
automatically add `./bin` to your `PATH` when you `cd` into your application.
|
|
64
|
+
Simply create an `.envrc` file with the command `PATH_add bin` in your
|
|
65
|
+
Rails directory.
|
|
66
66
|
|
|
67
67
|
### Usage
|
|
68
68
|
|
|
@@ -179,6 +179,17 @@ To remove spring:
|
|
|
179
179
|
* 'Unspring' your bin/ executables: `bin/spring binstub --remove --all`
|
|
180
180
|
* Remove spring from your Gemfile
|
|
181
181
|
|
|
182
|
+
### Deployment
|
|
183
|
+
|
|
184
|
+
You must not install Spring on your production environment. To prevent it from
|
|
185
|
+
being installed, provide the `--without development test` argument to the
|
|
186
|
+
`bundle install` command which is used to install gems on your production
|
|
187
|
+
machines:
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
$ bundle install --without development test
|
|
191
|
+
```
|
|
192
|
+
|
|
182
193
|
## Commands
|
|
183
194
|
|
|
184
195
|
### `rake`
|
|
@@ -207,8 +218,7 @@ speed-up).
|
|
|
207
218
|
|
|
208
219
|
### Additional commands
|
|
209
220
|
|
|
210
|
-
You can add these to your Gemfile for additional commands
|
|
211
|
-
to pick up the changes):
|
|
221
|
+
You can add these to your Gemfile for additional commands:
|
|
212
222
|
|
|
213
223
|
* [spring-commands-rspec](https://github.com/jonleighton/spring-commands-rspec)
|
|
214
224
|
* [spring-commands-cucumber](https://github.com/jonleighton/spring-commands-cucumber)
|
|
@@ -333,13 +343,10 @@ Spring.watch "config/some_config_file.yml"
|
|
|
333
343
|
|
|
334
344
|
By default Spring polls the filesystem for changes once every 0.2 seconds. This
|
|
335
345
|
method requires zero configuration, but if you find that it's using too
|
|
336
|
-
much CPU, then you can
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
You may need to add the [`listen` gem](https://github.com/guard/listen) to your `Gemfile`.
|
|
346
|
+
much CPU, then you can use event-based file system listening by
|
|
347
|
+
installing the
|
|
348
|
+
[spring-watcher-listen](https://github.com/jonleighton/spring-watcher-listen)
|
|
349
|
+
gem.
|
|
343
350
|
|
|
344
351
|
## Troubleshooting
|
|
345
352
|
|
data/Rakefile
CHANGED
data/lib/spring/application.rb
CHANGED
|
@@ -108,6 +108,9 @@ module Spring
|
|
|
108
108
|
if defined?(Rails) && Rails.application
|
|
109
109
|
watcher.add Rails.application.paths["config/initializers"]
|
|
110
110
|
watcher.add Rails.application.paths["config/database"]
|
|
111
|
+
if secrets_path = Rails.application.paths["config/secrets"]
|
|
112
|
+
watcher.add secrets_path
|
|
113
|
+
end
|
|
111
114
|
end
|
|
112
115
|
end
|
|
113
116
|
|
|
@@ -155,7 +158,7 @@ module Spring
|
|
|
155
158
|
trap("TERM", "DEFAULT")
|
|
156
159
|
|
|
157
160
|
ARGV.replace(args)
|
|
158
|
-
$0 = command.
|
|
161
|
+
$0 = command.exec_name
|
|
159
162
|
|
|
160
163
|
# Delete all env vars which are unchanged from before spring started
|
|
161
164
|
original_env.each { |k, v| ENV.delete k if ENV[k] == v }
|
|
@@ -267,6 +270,7 @@ module Spring
|
|
|
267
270
|
end
|
|
268
271
|
end
|
|
269
272
|
end
|
|
273
|
+
private :raise
|
|
270
274
|
end
|
|
271
275
|
end
|
|
272
276
|
|
|
@@ -279,6 +283,7 @@ module Spring
|
|
|
279
283
|
def with_pty
|
|
280
284
|
PTY.open do |master, slave|
|
|
281
285
|
[STDOUT, STDERR, STDIN].each { |s| s.reopen slave }
|
|
286
|
+
Thread.new { master.read }
|
|
282
287
|
yield
|
|
283
288
|
reset_streams
|
|
284
289
|
end
|
|
@@ -36,9 +36,9 @@ unless defined?(Spring)
|
|
|
36
36
|
require "rubygems"
|
|
37
37
|
require "bundler"
|
|
38
38
|
|
|
39
|
-
if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m)
|
|
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]
|
data/lib/spring/client/run.rb
CHANGED
|
@@ -21,7 +21,37 @@ module Spring
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def call
|
|
24
|
-
|
|
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 =
|
|
42
|
-
|
|
43
|
-
|
|
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
|
data/lib/spring/client/status.rb
CHANGED
|
@@ -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
|
|
20
|
+
puts `ps -p #{pid} -o pid= -o command=`
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def application_pids
|
|
24
|
-
candidates = `ps -
|
|
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
|
data/lib/spring/client/stop.rb
CHANGED
|
@@ -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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
@@ -13,7 +13,19 @@ module Spring
|
|
|
13
13
|
|
|
14
14
|
class RailsConsole < Rails
|
|
15
15
|
def env(args)
|
|
16
|
-
args.first if args.first && !args.first.index("-")
|
|
16
|
+
return args.first if args.first && !args.first.index("-")
|
|
17
|
+
|
|
18
|
+
environment = nil
|
|
19
|
+
|
|
20
|
+
args.each.with_index do |arg, i|
|
|
21
|
+
if arg =~ /--environment=(\w+)/
|
|
22
|
+
environment = $1
|
|
23
|
+
elsif i > 0 && args[i - 1] == "-e"
|
|
24
|
+
environment = arg
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
environment
|
|
17
29
|
end
|
|
18
30
|
|
|
19
31
|
def command_name
|
data/lib/spring/commands.rb
CHANGED
|
@@ -32,8 +32,17 @@ module Spring
|
|
|
32
32
|
# then we need to be under bundler.
|
|
33
33
|
require "bundler/setup"
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
# Auto-require any spring extensions which are in the Gemfile
|
|
36
|
+
Gem::Specification.map(&:name).grep(/^spring-/).each do |command|
|
|
37
|
+
begin
|
|
38
|
+
require command
|
|
39
|
+
rescue LoadError => error
|
|
40
|
+
if error.message.include?(command)
|
|
41
|
+
require command.gsub("-", "/")
|
|
42
|
+
else
|
|
43
|
+
raise
|
|
44
|
+
end
|
|
45
|
+
end
|
|
37
46
|
end
|
|
38
47
|
|
|
39
48
|
config = File.expand_path("./config/spring.rb")
|
data/lib/spring/env.rb
CHANGED
|
@@ -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
|
|
@@ -32,13 +33,13 @@ module Spring
|
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
def tmp_path
|
|
35
|
-
path = Pathname.new(Dir.tmpdir
|
|
36
|
+
path = Pathname.new(File.join(ENV['XDG_RUNTIME_DIR'] || Dir.tmpdir, "spring"))
|
|
36
37
|
FileUtils.mkdir_p(path) unless path.exist?
|
|
37
38
|
path
|
|
38
39
|
end
|
|
39
40
|
|
|
40
41
|
def application_id
|
|
41
|
-
Digest::MD5.hexdigest(project_root.to_s)
|
|
42
|
+
Digest::MD5.hexdigest(RUBY_VERSION + project_root.to_s)
|
|
42
43
|
end
|
|
43
44
|
|
|
44
45
|
def socket_path
|
|
@@ -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
|