spring 0.9.1 → 1.0.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/CHANGELOG.md +24 -0
- data/README.md +5 -9
- data/lib/spring/application.rb +10 -5
- data/lib/spring/env.rb +16 -15
- data/lib/spring/errors.rb +0 -14
- data/lib/spring/server.rb +7 -3
- data/lib/spring/version.rb +1 -1
- data/spring.gemspec +1 -0
- data/test/acceptance/app_test.rb +11 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ab103d29ee132ac8637c7ddca8d5c41fc567c31e
|
|
4
|
+
data.tar.gz: 88e600c6e1d59b4150625769f20f6d543958087c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b4d762562b8d4c1832bcec43819b6bcc6d9168473095fac089a743c0c421d4450f77e7c0a3cf31902256ed42a3d0fa57e7767cd4a0cf9d0bd55dc24c758f460
|
|
7
|
+
data.tar.gz: 9c929b2636980dc30486f475caeacb1f3de296420c22e9f0a52c67ce732a8953e28f1b090258a18456d210ce217610e8e4df8ffeb7a1a8ebd0e2b546554235ec
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
## 1.0.0
|
|
2
|
+
|
|
3
|
+
* Enterprise ready secret sauce added
|
|
4
|
+
|
|
5
|
+
## 0.9.2
|
|
6
|
+
|
|
7
|
+
* Bugfix: environment variables set by bundler (`BUNDLE_GEMFILE`,
|
|
8
|
+
`RUBYOPT`, etc...) were being removed from the environment.
|
|
9
|
+
* Ensure we only run the code reloader when files have actually changed.
|
|
10
|
+
This issue became more prominent with Rails 4, since Rails 4 will now
|
|
11
|
+
reload routes whenever the code is reloaded (see
|
|
12
|
+
https://github.com/rails/rails/commit/b9b06daa915fdc4d11e8cfe11a7175e5cd8f104f).
|
|
13
|
+
* Allow spring to be used in a descendant directory of the application
|
|
14
|
+
root
|
|
15
|
+
* Use the system tmpdir for our temporary files. Previously we used
|
|
16
|
+
`APP_ROOT/tmp/spring`, which caused problems on filesystems which did
|
|
17
|
+
not support sockets, and also caused problems if `APP_ROOT` was
|
|
18
|
+
sufficiently deep in the filesystem to exhaust the operating system's
|
|
19
|
+
socket name limit. Hence we had a `SPRING_TMP_PATH` environment
|
|
20
|
+
variable for configuration. We now use `/tmp/spring/[md5(APP_ROOT)]`
|
|
21
|
+
for the socket and `/tmp/spring/[md5(APP_ROOT)].pid` for the pid file.
|
|
22
|
+
Thanks @Kriechi for the suggestion. Setting `SPRING_TMP_PATH` no longer
|
|
23
|
+
has any effect.
|
|
24
|
+
|
|
1
25
|
## 0.9.1
|
|
2
26
|
|
|
3
27
|
* Environment variables which were created during application startup are no
|
data/README.md
CHANGED
|
@@ -162,7 +162,7 @@ Custom commands can be specified in the Spring config file. See
|
|
|
162
162
|
[`lib/spring/commands/`](https://github.com/jonleighton/spring/blob/master/lib/spring/commands/)
|
|
163
163
|
for examples.
|
|
164
164
|
|
|
165
|
-
You can
|
|
165
|
+
You can add the following gems to your Gemfile for additional commands:
|
|
166
166
|
|
|
167
167
|
* [spring-commands-rspec](https://github.com/jonleighton/spring-commands-rspec)
|
|
168
168
|
* [spring-commands-cucumber](https://github.com/jonleighton/spring-commands-cucumber)
|
|
@@ -198,9 +198,10 @@ speed-up).
|
|
|
198
198
|
|
|
199
199
|
Spring will read `~/.spring.rb` and `config/spring.rb` for custom
|
|
200
200
|
settings. Note that `~/.spring.rb` is loaded *before* bundler, but
|
|
201
|
-
`config/spring.rb` is loaded *after* bundler.
|
|
202
|
-
|
|
203
|
-
to be
|
|
201
|
+
`config/spring.rb` is loaded *after* bundler. So if you have any
|
|
202
|
+
`spring-commands-*` gems installed that you want to be available in all
|
|
203
|
+
projects without having to be added to the project's Gemfile, require
|
|
204
|
+
them in your `~/.spring.rb`.
|
|
204
205
|
|
|
205
206
|
### Application root
|
|
206
207
|
|
|
@@ -264,11 +265,6 @@ Spring.watch_method = :listen
|
|
|
264
265
|
|
|
265
266
|
You may need to add the [`listen` gem](https://github.com/guard/listen) to your `Gemfile`.
|
|
266
267
|
|
|
267
|
-
### tmp directory
|
|
268
|
-
|
|
269
|
-
Spring needs a tmp directory. This will default to `Rails.root.join('tmp', 'spring')`.
|
|
270
|
-
You can set your own configuration directory by setting the `SPRING_TMP_PATH` environment variable.
|
|
271
|
-
|
|
272
268
|
## Troubleshooting
|
|
273
269
|
|
|
274
270
|
If you want to get more information about what spring is doing, you can
|
data/lib/spring/application.rb
CHANGED
|
@@ -15,7 +15,6 @@ module Spring
|
|
|
15
15
|
@mutex = Mutex.new
|
|
16
16
|
@waiting = 0
|
|
17
17
|
@exiting = false
|
|
18
|
-
@env_keys = ENV.keys
|
|
19
18
|
|
|
20
19
|
# Workaround for GC bug in Ruby 2 which causes segfaults if watcher.to_io
|
|
21
20
|
# instances get dereffed.
|
|
@@ -99,8 +98,10 @@ module Spring
|
|
|
99
98
|
connect_database
|
|
100
99
|
setup command
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
if Rails.application.reloaders.any?(&:updated?)
|
|
102
|
+
ActionDispatch::Reloader.cleanup!
|
|
103
|
+
ActionDispatch::Reloader.prepare!
|
|
104
|
+
end
|
|
104
105
|
|
|
105
106
|
pid = fork {
|
|
106
107
|
Process.setsid
|
|
@@ -108,8 +109,12 @@ module Spring
|
|
|
108
109
|
IGNORE_SIGNALS.each { |sig| trap(sig, "DEFAULT") }
|
|
109
110
|
|
|
110
111
|
ARGV.replace(args)
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
|
|
113
|
+
# Delete all env vars which are unchanged from before spring started
|
|
114
|
+
Spring.original_env.each { |k, v| ENV.delete k if ENV[k] == v }
|
|
115
|
+
|
|
116
|
+
# Load in the current env vars, except those which *were* changed when spring started
|
|
117
|
+
env.each { |k, v| ENV[k] ||= v }
|
|
113
118
|
|
|
114
119
|
connect_database
|
|
115
120
|
srand
|
data/lib/spring/env.rb
CHANGED
|
@@ -1,32 +1,43 @@
|
|
|
1
1
|
require "pathname"
|
|
2
2
|
require "fileutils"
|
|
3
|
+
require "digest/md5"
|
|
4
|
+
require "tmpdir"
|
|
3
5
|
|
|
4
6
|
require "spring/version"
|
|
5
7
|
require "spring/sid"
|
|
8
|
+
require "spring/configuration"
|
|
6
9
|
|
|
7
10
|
module Spring
|
|
8
11
|
IGNORE_SIGNALS = %w(INT QUIT)
|
|
9
12
|
|
|
10
13
|
class Env
|
|
11
|
-
attr_reader :
|
|
14
|
+
attr_reader :log_file
|
|
12
15
|
|
|
13
16
|
def initialize(root = nil)
|
|
14
|
-
@root = root
|
|
17
|
+
@root = root
|
|
15
18
|
@log_file = File.open(ENV["SPRING_LOG"] || "/dev/null", "a")
|
|
16
19
|
end
|
|
17
20
|
|
|
21
|
+
def root
|
|
22
|
+
@root ||= Spring.application_root_path
|
|
23
|
+
end
|
|
24
|
+
|
|
18
25
|
def version
|
|
19
26
|
Spring::VERSION
|
|
20
27
|
end
|
|
21
28
|
|
|
22
29
|
def tmp_path
|
|
23
|
-
path =
|
|
30
|
+
path = Pathname.new(Dir.tmpdir + "/spring")
|
|
24
31
|
FileUtils.mkdir_p(path) unless path.exist?
|
|
25
32
|
path
|
|
26
33
|
end
|
|
27
34
|
|
|
35
|
+
def application_id
|
|
36
|
+
Digest::MD5.hexdigest(root.to_s)
|
|
37
|
+
end
|
|
38
|
+
|
|
28
39
|
def socket_path
|
|
29
|
-
tmp_path.join(
|
|
40
|
+
tmp_path.join(application_id)
|
|
30
41
|
end
|
|
31
42
|
|
|
32
43
|
def socket_name
|
|
@@ -34,7 +45,7 @@ module Spring
|
|
|
34
45
|
end
|
|
35
46
|
|
|
36
47
|
def pidfile_path
|
|
37
|
-
tmp_path.join("
|
|
48
|
+
tmp_path.join("#{application_id}.pid")
|
|
38
49
|
end
|
|
39
50
|
|
|
40
51
|
def pid
|
|
@@ -68,15 +79,5 @@ module Spring
|
|
|
68
79
|
log_file.puts "[#{Time.now}] #{message}"
|
|
69
80
|
log_file.flush
|
|
70
81
|
end
|
|
71
|
-
|
|
72
|
-
private
|
|
73
|
-
|
|
74
|
-
def default_tmp_path
|
|
75
|
-
if ENV['SPRING_TMP_PATH']
|
|
76
|
-
Pathname.new(ENV['SPRING_TMP_PATH'])
|
|
77
|
-
else
|
|
78
|
-
root.join('tmp/spring')
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
82
|
end
|
|
82
83
|
end
|
data/lib/spring/errors.rb
CHANGED
|
@@ -15,20 +15,6 @@ module Spring
|
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
class TmpUnwritable < StandardError
|
|
19
|
-
attr_reader :tmp_path
|
|
20
|
-
|
|
21
|
-
def initialize(tmp_path)
|
|
22
|
-
@tmp_path = tmp_path
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def message
|
|
26
|
-
"Spring is unable to create a socket file at #{tmp_path}. You may need to " \
|
|
27
|
-
"set the SPRING_TMP_PATH environment variable to use a different path. See " \
|
|
28
|
-
"the documentation for details."
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
18
|
class MissingApplication < ClientError
|
|
33
19
|
attr_reader :project_root
|
|
34
20
|
|
data/lib/spring/server.rb
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
module Spring
|
|
2
|
+
class << self
|
|
3
|
+
attr_reader :original_env
|
|
4
|
+
end
|
|
5
|
+
@original_env = ENV.to_hash
|
|
6
|
+
end
|
|
7
|
+
|
|
1
8
|
require "socket"
|
|
2
9
|
require "thread"
|
|
3
10
|
|
|
@@ -48,9 +55,6 @@ module Spring
|
|
|
48
55
|
def start_server
|
|
49
56
|
server = UNIXServer.open(env.socket_name)
|
|
50
57
|
log "started on #{env.socket_name}"
|
|
51
|
-
rescue Errno::EPERM
|
|
52
|
-
raise TmpUnwritable.new(env.tmp_path)
|
|
53
|
-
else
|
|
54
58
|
loop { serve server.accept }
|
|
55
59
|
end
|
|
56
60
|
|
data/lib/spring/version.rb
CHANGED
data/spring.gemspec
CHANGED
|
@@ -11,6 +11,7 @@ Gem::Specification.new do |gem|
|
|
|
11
11
|
gem.description = %q{Rails application preloader}
|
|
12
12
|
gem.summary = %q{Rails application preloader}
|
|
13
13
|
gem.homepage = "http://github.com/jonleighton/spring"
|
|
14
|
+
gem.license = "MIT"
|
|
14
15
|
|
|
15
16
|
gem.files = `git ls-files`.split($/)
|
|
16
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
data/test/acceptance/app_test.rb
CHANGED
|
@@ -179,8 +179,10 @@ class AppTest < ActiveSupport::TestCase
|
|
|
179
179
|
|
|
180
180
|
def generate_app
|
|
181
181
|
Bundler.with_clean_env do
|
|
182
|
+
# Sporadic SSL errors keep causing test failures so there are anti-SSL workarounds here
|
|
183
|
+
|
|
182
184
|
assert system("(gem list rails --installed --version '#{rails_version}' || " \
|
|
183
|
-
"gem install rails --version '#{rails_version}') > /dev/null")
|
|
185
|
+
"gem install rails --clear-sources --source http://rubygems.org --version '#{rails_version}') > /dev/null")
|
|
184
186
|
|
|
185
187
|
# Have to shell out otherwise bundler prevents us finding the gem
|
|
186
188
|
version = `ruby -e 'puts Gem::Specification.find_by_name("rails", "#{rails_version}").version'`.chomp
|
|
@@ -197,6 +199,11 @@ class AppTest < ActiveSupport::TestCase
|
|
|
197
199
|
File.read("#{app_root}/Gemfile") + "gem 'spring-commands-testunit'\n"
|
|
198
200
|
)
|
|
199
201
|
end
|
|
202
|
+
|
|
203
|
+
File.write(
|
|
204
|
+
"#{app_root}/Gemfile",
|
|
205
|
+
File.read("#{app_root}/Gemfile").sub("https://rubygems.org", "http://rubygems.org")
|
|
206
|
+
)
|
|
200
207
|
end
|
|
201
208
|
end
|
|
202
209
|
|
|
@@ -485,9 +492,12 @@ class AppTest < ActiveSupport::TestCase
|
|
|
485
492
|
|
|
486
493
|
env["OMG"] = "1"
|
|
487
494
|
env["FOO"] = "1"
|
|
495
|
+
env["RUBYOPT"] = "-rubygems"
|
|
488
496
|
|
|
489
497
|
assert_success %(#{spring} rails runner 'p ENV["OMG"]'), stdout: "1"
|
|
490
498
|
assert_success %(#{spring} rails runner 'p ENV["BAR"]'), stdout: "bar"
|
|
499
|
+
assert_success %(#{spring} rails runner 'p ENV.key?("BUNDLE_GEMFILE")'), stdout: "true"
|
|
500
|
+
assert_success %(#{spring} rails runner 'p ENV["RUBYOPT"]'), stdout: "bundler"
|
|
491
501
|
|
|
492
502
|
env["OMG"] = "2"
|
|
493
503
|
env.delete "FOO"
|
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: 0.
|
|
4
|
+
version: 1.0.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: 2013-11-
|
|
11
|
+
date: 2013-11-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -88,7 +88,8 @@ files:
|
|
|
88
88
|
- test/unit/process_title_updater_test.rb
|
|
89
89
|
- test/unit/watcher_test.rb
|
|
90
90
|
homepage: http://github.com/jonleighton/spring
|
|
91
|
-
licenses:
|
|
91
|
+
licenses:
|
|
92
|
+
- MIT
|
|
92
93
|
metadata: {}
|
|
93
94
|
post_install_message:
|
|
94
95
|
rdoc_options: []
|
|
@@ -118,4 +119,3 @@ test_files:
|
|
|
118
119
|
- test/unit/commands_test.rb
|
|
119
120
|
- test/unit/process_title_updater_test.rb
|
|
120
121
|
- test/unit/watcher_test.rb
|
|
121
|
-
has_rdoc:
|