-
Notifications
You must be signed in to change notification settings - Fork 900
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
Require config environment over rails runner #11399
Require config environment over rails runner #11399
Conversation
Benefits: * rails runner is for shebang lines or inline ruby, see ManageIQ#4307 * We don't have to check if rails is loaded. * Can be run outside rails root directory via ruby. * We don't need -- to avoid rails runner modifying our args. * Less typing. * Existing bin/rails runner callers with args just work: `ruby tools/purge_orphaned_tag_values.rb -s 100` Or, the old way: `bin/rails runner tools/purge_orphaned_tag_values.rb -- -s 100` Discovered while reviewing: ManageIQ#11281
Checked commits jrafanie/manageiq@6e29c84~...7e97acf with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 tools/purge_metrics.rb
tools/purge_miq_report_results.rb
tools/purge_orphaned_tag_values.rb
|
Chill ❄️ rubocop❄️ , I'm not touching those style changes in this PR. |
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 like it for consistency :)
👍 If you happen to run with rails runner, things will still work, right? |
@@ -1,10 +1,10 @@ | |||
require File.expand_path('../config/environment', __dir__) |
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.
Pedantic (possibly for another PR): Would adding a #!/usr/bin/env ruby
at the top here makes sense and making these executable?
I assume there is a reason they are not already, but it would just cut down on the typing further:
ruby tools/purge_orphaned_tag_values.rb -s 100
v.s. tools/purge_orphaned_tag_values.rb -s 100
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 assume there is a reason they are not already, but it would just cut down on the typing further:
Probably because of appliance rpm business. I believe shebang lines will work properly in the appliance multiple ruby environment with system ruby from CentOS/RHEL and having packaged 2.2+ ruby from software collections. I don't have an appliance with system ruby rpm and scl ruby rpm at the same time.
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.
It's a good idea, but I believe it involves more testing than this PR does.
@Fryguy Yes, I tried each of these with ruby and rails runner. So, both of these work:
Or, the old way: I didn't remove the shifting of the "--" in the event it's coming from rails runner invocation. |
Benefits:
ruby tools/purge_orphaned_tag_values.rb -s 100
Or, the old way:
bin/rails runner tools/purge_orphaned_tag_values.rb -- -s 100
Discovered while reviewing: #11281