-
Notifications
You must be signed in to change notification settings - Fork 30
Switch to rails runner
approach instead of Rack app
#256
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
# typed: strict | ||
# frozen_string_literal: true | ||
|
||
require "sorbet-runtime" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ( |
||
require "pathname" | ||
|
||
require "ruby_lsp_rails/version" | ||
require "ruby_lsp_rails/railtie" | ||
|
||
|
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,34 +2,17 @@ | |
# frozen_string_literal: true | ||
|
||
require "rails" | ||
require "ruby_lsp_rails/rack_app" | ||
|
||
module RubyLsp | ||
module Rails | ||
class Railtie < ::Rails::Railtie | ||
config.ruby_lsp_rails = ActiveSupport::OrderedOptions.new | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's maybe keep the railtie so we can print deprecation warning for apps assigning I think upgrading There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking that originally, but after discussing with @vinistock, probably very few apps are likely to be using this. For Core, we can remove the setting when updating the gem. We're also tagging this PR as a 'breaking change' for awareness. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, this and the version change will technically justify it, but they won't show up in the users' bump PR I think. Given that:
I don't want to underestimate the negative effect this may cause to our users, especially when it's actually not too costly to avoid. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I highly doubt a lot of people are turning off the server, but if you feel strongly about this we can add a deprecation warning and then remove it later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done (and verified against Code DB). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks 👍 I want to be super careful about this because I did already find 2 (though inactive) repos having this set just doing a quick search. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose people may also have disabled this because they didn't like the extra noise in their logs. |
||
config.ruby_lsp_rails.server = true | ||
|
||
initializer "ruby_lsp_rails.setup" do |_app| | ||
config.after_initialize do |app| | ||
# If we start the app with `bin/rails console` then `Rails::Server` is not defined. | ||
if defined?(::Rails::Server) && config.ruby_lsp_rails.server | ||
app.routes.prepend do | ||
T.bind(self, ActionDispatch::Routing::Mapper) | ||
mount(RackApp.new => RackApp::BASE_PATH) | ||
end | ||
|
||
ssl_enable, host, port = ::Rails::Server::Options.new.parse!(ARGV).values_at(:SSLEnable, :Host, :Port) | ||
app_uri = "#{ssl_enable ? "https" : "http"}://#{host}:#{port}" | ||
app_uri_path = ::Rails.root.join("tmp", "app_uri.txt") | ||
app_uri_path.write(app_uri) | ||
|
||
at_exit do | ||
# The app_uri.txt file should only exist when the server is running. The addon uses its presence to | ||
# report if the server is running or not. If the server is not running, some of the addon features | ||
# will not be available. | ||
File.delete(app_uri_path) if File.exist?(app_uri_path) | ||
end | ||
config.after_initialize do |_app| | ||
unless config.ruby_lsp_rails.server.nil? | ||
ActiveSupport::Deprecation.new.warn("The `ruby_lsp_rails.server` configuration option is no longer " \ | ||
"needed and will be removed in a future release.") | ||
end | ||
end | ||
end | ||
|
Uh oh!
There was an error while loading. Please reload this page.