Skip to content

Commit

Permalink
Print "Running via Spring preloader" message from the app process
Browse files Browse the repository at this point in the history
Rather than from the Spring client process. See
https://github.com/rails/spring/pull/455/files#r48411471

Within the app process, we'll have access to the spring config, to see
whether Spring.quiet has been set.

This means we can remove the spring/commands require from the client
side, which should never have been added and caused problems (#456, #457).

I'm getting rid of the feature which omits this message when run
manually (i.e. `spring rails runner ...` rather than `bin/rails runner
...`) because:

1. It makes the implementation more complicated
2. YAGNI
  • Loading branch information
jonleighton committed Jan 8, 2016
1 parent 8fff76c commit 0a80019
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Next release

* Fix problems with the implementation of the new "Running via Spring preloader"
message (see #456, #457)

## 1.6.1

* support replaced backtraces / backtraces with only line and number
Expand Down
2 changes: 0 additions & 2 deletions bin/spring
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,4 @@ end
lib = File.expand_path("../../lib", __FILE__)
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib) # enable local development
require 'spring/client'
# if the user knows that spring is called, do not show running spring
Spring.quiet = true if $0.include? 'spring'
Spring::Client.run(ARGV)
2 changes: 2 additions & 0 deletions lib/spring/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ def serve(client)
IGNORE_SIGNALS.each { |sig| trap(sig, "DEFAULT") }
trap("TERM", "DEFAULT")

puts "Running via Spring preloader in process #{Process.pid}" unless Spring.quiet

ARGV.replace(args)
$0 = command.exec_name

Expand Down
3 changes: 0 additions & 3 deletions lib/spring/client/run.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require "spring/commands"
require "rbconfig"
require "socket"
require "bundler"
Expand Down Expand Up @@ -139,8 +138,6 @@ def run_command(client, application)
if pid && !pid.empty?
log "got pid: #{pid}"

puts "Running via Spring preloader in process #{pid}" unless Spring.quiet

forward_signals(pid.to_i)
status = application.read.to_i

Expand Down
5 changes: 0 additions & 5 deletions lib/spring/test/acceptance_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ def without_gem(name)
assert_success app.spring_test_command, stdout: "Running via Spring preloader in process"
end

test "does not tell the user that spring is being used when the user used spring manually" do
refute_output_includes "spring rails runner ''", stdout: "Running via Spring preloader in process"
refute_output_includes "spring rake test", stdout: "Running via Spring preloader in process"
end

test "does not tell the user that spring is being used when used automatically via binstubs but quiet is enabled" do
File.write("#{app.user_home}/.spring.rb", "Spring.quiet = true")
assert_success "bin/rails runner ''"
Expand Down

0 comments on commit 0a80019

Please sign in to comment.