Skip to content

Ensure app_uri.txt is cleaned up when Rails server shuts down #87

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

Merged
merged 1 commit into from
Jun 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/ruby_lsp_rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ class Railtie < ::Rails::Railtie
if defined?(::Rails::Server)
ssl_enable, host, port = ::Rails::Server::Options.new.parse!(ARGV).values_at(:SSLEnable, :Host, :Port)
app_uri = "#{ssl_enable ? "https" : "http"}://#{host}:#{port}"
File.write("#{::Rails.root}/tmp/app_uri.txt", app_uri)
app_uri_path = "#{::Rails.root}/tmp/app_uri.txt"
File.write(app_uri_path, app_uri)

at_exit do
# The app_uri.txt file should only exist when the server is running. The extension uses its presence to
# report if the server is running or not. If the server is not running, some of the extension features
# will not be available.
File.delete(app_uri_path) if File.exist?(app_uri_path)
end
end
end
end
Expand Down