Skip to content

Commit db2aa4f

Browse files
committed
Start process title updater ASAP
Otherwise it might get stuck behind the call to #preload. It also doesn't really need to be in Application.
1 parent 4b5e2da commit db2aa4f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lib/spring/application.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ def app_env
3131
ENV['RAILS_ENV']
3232
end
3333

34+
def app_name
35+
spring_env.app_name
36+
end
37+
3438
def log(message)
3539
spring_env.log "[application:#{app_env}] #{message}"
3640
end
@@ -107,7 +111,6 @@ def preload
107111
def run
108112
state :running
109113
manager.puts
110-
update_process_title
111114

112115
loop do
113116
IO.select [manager, @interrupt.first]
@@ -269,11 +272,5 @@ def print_exception(stream, error)
269272
stream.puts("#{first}: #{error} (#{error.class})")
270273
rest.each { |line| stream.puts("\tfrom #{line}") }
271274
end
272-
273-
def update_process_title
274-
ProcessTitleUpdater.run { |distance|
275-
"spring app | #{spring_env.app_name} | started #{distance} ago | #{app_env} mode"
276-
}
277-
end
278275
end
279276
end

lib/spring/application/boot.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
UNIXSocket.for_fd(3),
55
Spring::JSON.load(ENV.delete("SPRING_ORIGINAL_ENV").dup)
66
)
7+
78
Signal.trap("TERM") { app.terminate }
89
Signal.trap("TTOU", "IGNORE")
910

11+
Spring::ProcessTitleUpdater.run { |distance|
12+
"spring app | #{app.app_name} | started #{distance} ago | #{app.app_env} mode"
13+
}
14+
1015
app.preload if ENV.delete("SPRING_PRELOAD") == "1"
1116
app.run

0 commit comments

Comments
 (0)