spring 1.0.0 → 1.1.1

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.
data/lib/spring/server.rb CHANGED
@@ -1,26 +1,13 @@
1
1
  module Spring
2
- class << self
3
- attr_reader :original_env
4
- end
5
- @original_env = ENV.to_hash
2
+ ORIGINAL_ENV = ENV.to_hash
6
3
  end
7
4
 
8
- require "socket"
9
- require "thread"
10
-
11
- require "spring/configuration"
12
- require "spring/env"
5
+ require "spring/boot"
13
6
  require "spring/application_manager"
14
- require "spring/process_title_updater"
15
- require "spring/json"
16
7
 
17
- # Must be last, as it requires bundler/setup
8
+ # Must be last, as it requires bundler/setup, which alters the load path
18
9
  require "spring/commands"
19
10
 
20
- # readline must be required before we setpgid, otherwise the require may hang,
21
- # if readline has been built against libedit. See issue #70.
22
- require "readline"
23
-
24
11
  module Spring
25
12
  class Server
26
13
  def self.boot
@@ -31,7 +18,7 @@ module Spring
31
18
 
32
19
  def initialize(env = Env.new)
33
20
  @env = env
34
- @applications = Hash.new { |h, k| h[k] = ApplicationManager.new(self, k) }
21
+ @applications = Hash.new { |h, k| h[k] = ApplicationManager.new(k) }
35
22
  @pidfile = env.pidfile_path.open('a')
36
23
  @mutex = Mutex.new
37
24
  end
@@ -48,7 +35,6 @@ module Spring
48
35
  ignore_signals
49
36
  set_exit_hook
50
37
  set_process_title
51
- watch_bundle
52
38
  start_server
53
39
  end
54
40
 
@@ -82,13 +68,7 @@ module Spring
82
68
  end
83
69
 
84
70
  def rails_env_for(args, default_rails_env)
85
- command = Spring.command(args.first)
86
-
87
- if command.respond_to?(:env)
88
- env = command.env(args.drop(1))
89
- end
90
-
91
- env || default_rails_env
71
+ Spring.command(args.first).env(args.drop(1)) || default_rails_env
92
72
  end
93
73
 
94
74
  # Boot the server into the process group of the current session.
@@ -101,7 +81,7 @@ module Spring
101
81
  # Ignore SIGINT and SIGQUIT otherwise the user typing ^C or ^\ on the command line
102
82
  # will kill the server/application.
103
83
  def ignore_signals
104
- IGNORE_SIGNALS.each { |sig| trap(sig, "IGNORE") }
84
+ IGNORE_SIGNALS.each { |sig| trap(sig, "IGNORE") }
105
85
  end
106
86
 
107
87
  def set_exit_hook
@@ -112,13 +92,13 @@ module Spring
112
92
  end
113
93
 
114
94
  def shutdown
115
- @applications.values.each(&:stop)
116
-
117
95
  [env.socket_path, env.pidfile_path].each do |path|
118
96
  if path.exist?
119
97
  path.unlink rescue nil
120
98
  end
121
99
  end
100
+
101
+ @applications.values.map { |a| Thread.new { a.stop } }.map(&:join)
122
102
  end
123
103
 
124
104
  def write_pidfile
@@ -144,13 +124,5 @@ module Spring
144
124
  "spring server | #{env.app_name} | started #{distance} ago"
145
125
  }
146
126
  end
147
-
148
- def watch_bundle
149
- @bundle_mtime = env.bundle_mtime
150
- end
151
-
152
- def application_starting
153
- @mutex.synchronize { exit if env.bundle_mtime != @bundle_mtime }
154
- end
155
127
  end
156
128
  end
@@ -1,3 +1,3 @@
1
1
  module Spring
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -22,7 +22,7 @@ module Spring
22
22
  @files = Set.new
23
23
  @directories = Set.new
24
24
  @stale = false
25
- @io_listener = nil
25
+ @listeners = []
26
26
  end
27
27
 
28
28
  def add(*items)
@@ -55,15 +55,14 @@ module Spring
55
55
  @stale
56
56
  end
57
57
 
58
- def mark_stale
59
- @stale = true
60
- @io_listener.write "." if @io_listener
58
+ def on_stale(&block)
59
+ @listeners << block
61
60
  end
62
61
 
63
- def to_io
64
- read, write = IO.pipe
65
- @io_listener = write
66
- read
62
+ def mark_stale
63
+ return if stale?
64
+ @stale = true
65
+ @listeners.each(&:call)
67
66
  end
68
67
 
69
68
  def restart
data/spring.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.email = ["j@jonathanleighton.com"]
11
11
  gem.description = %q{Rails application preloader}
12
12
  gem.summary = %q{Rails application preloader}
13
- gem.homepage = "http://github.com/jonleighton/spring"
13
+ gem.homepage = "http://github.com/rails/spring"
14
14
  gem.license = "MIT"
15
15
 
16
16
  gem.files = `git ls-files`.split($/)