-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
print spring client pid on command run #455
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @rafaelfranca (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
how about:
|
@grosser I don't know if I got this right, but for this we need to differentiate between two types of commands (namely Spring::Client.run(ARGV) ARGV is same for both cases ( |
$0 for bin/rails is ./bin/rails and for spring is rails_runner On Sat, Dec 12, 2015 at 9:11 PM, Aditya Prakash [email protected]
|
done! |
@@ -46,4 +46,5 @@ end | |||
lib = File.expand_path("../../lib", __FILE__) | |||
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib) # enable local development | |||
require 'spring/client' | |||
Spring.verbose_output = false if $0.include? 'spring' # don't output running spring status if command has `spring` in it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about: Spring.verbose_output = $0.include?('spring')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the comment repeats the code, how about:
if the user knows that spring is called, do not show that spring is called
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about: Spring.verbose_output = $0.include?('spring')
I think you meant Spring.verbose_output = !$0.include?('spring')
It is not going to work cause it will set Spring.verbose_output
to true
when command includesspring
, even when user has Spring.verbose_output = false
defined in config/spring.rb
(or ~/.spring.rb
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yeah, makes sense
On Sat, Dec 12, 2015 at 11:44 PM, Aditya Prakash [email protected]
wrote:
In bin/spring
#455 (comment):@@ -46,4 +46,5 @@ end
lib = File.expand_path("../../lib", FILE)
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib) # enable local development
require 'spring/client'
+Spring.verbose_output = false if $0.include? 'spring' # don't output running spring status if command hasspring
in ithow about: Spring.verbose_output = $0.include?('spring')
I think you meant Spring.verbose_output = !$0.include?('spring')
It is not going to work it will set Spring.verbose_output to true when
command includesspring, even when user has Spring.verbose_output = false
defined in config/spring.rb (or ~/.spring.rb).—
Reply to this email directly or view it on GitHub
https://github.com/rails/spring/pull/455/files#r47441438.
👍 @jonleighton looks good ? |
652d544
to
e06c4fd
Compare
@@ -49,4 +49,6 @@ def find_project_root(current_dir) | |||
end | |||
end | |||
end | |||
|
|||
self.verbose_output = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling the option "verbose" makes me think that it produces more than the normal amount of output. However the default is "verbose" mode.
I'd call this Spring.quiet
instead, and have it default to false. Then you're opting in to quietness, rather than the opting out of verbosity. (I also think the _output
bit is superfluous.)
Made some comments but generally 👍 |
e06c4fd
to
70207b9
Compare
70207b9
to
8964a36
Compare
@jonleighton @grosser Thanks for getting me through it 😝 I have made the changes you requested. |
@@ -94,6 +102,22 @@ def without_gem(name) | |||
refute app.spring_env.server_running? | |||
end | |||
|
|||
test "running spring status for rails/rake commands" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these descriptions could make it easier for other users to understand what is being tested:
test "tells the user that spring is being used when used automatically via binstubs"
test "does not tell the user that spring is being used when the user used spring manually"
test "does not tell the user that spring is being when used automatically via binstubs but quiet is enabled"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
8964a36
to
3fba9df
Compare
3fba9df
to
20383d6
Compare
thx, I'll merge when travis is green :) |
hey, a quick question: Is |
looks unused ... can you make a cleanup PR to remove it ? On Mon, Dec 14, 2015 at 9:41 AM, Aditya Prakash [email protected]
|
here we got! |
print spring client pid on command run
have fun with 1.6.0 :) |
yay 🎉 |
I think I just put it there to avoid having magic numbers in the code. I don't think we should hardcode something like this. |
I was wrong that it is not serving any purpose. (check this travis run). |
@@ -1,3 +1,4 @@ | |||
require "spring/commands" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sonalkr132 hey, quick question. I was wondering why you added this line? I'm getting an exception which seems to go away when I remove this line (which I've logged here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to require spring/command
cause it loads the user defined config files (config/spring.rb
or ~/.spring.rb
).
If user has defined Spring.quite
on one of those files then we need different behavior here:
puts "Running via Spring preloader in process #{pid}" unless Spring.quiet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sonalkr132 @grosser I missed this, but we shouldn't be requiring spring/commands
in the client. apart from this issue that @hsume2 reported, loading bundler in the client slows down the execution of spring commands, which is exactly what we want to avoid. The client needs to run as quickly as possible.
For client-side configuration, there is the config/spring_client.rb
file, so in theory the user could set Spring.quiet
in there (although I don't think this is really something we need to document...)
After fixing this, it would be great if we could somehow prevent a similar bug from being reintroduced in the future (perhaps we can somehow write a test which asserts that bundler is not present in the client? I don't know)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So,Spring.quite
option can only be set in spring_client.rb
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the current implementation, I think the answer should be yes. However I think that actually we could write this "Running via Spring preloader" message in Application#serve
, by which point spring/commands
would be loaded. So I think that may be a better option.
Resolves #407