From d314a3d5a674eb4583f600a4ad5fbd58e7e6d503 Mon Sep 17 00:00:00 2001 From: pratyush07-hub Date: Thu, 9 Apr 2026 18:19:35 +0530 Subject: [PATCH 1/5] Support launching with rackup on Rack 3 --- lib/rack/handler/rage.rb | 1 + lib/rackup/handler/rage.rb | 1 + lib/rage-rb.rb | 7 +++++++ lib/rage/handler.rb | 11 +++++++++++ 4 files changed, 20 insertions(+) create mode 100644 lib/rack/handler/rage.rb create mode 100644 lib/rackup/handler/rage.rb create mode 100644 lib/rage/handler.rb diff --git a/lib/rack/handler/rage.rb b/lib/rack/handler/rage.rb new file mode 100644 index 00000000..dfcba731 --- /dev/null +++ b/lib/rack/handler/rage.rb @@ -0,0 +1 @@ +require "rage" \ No newline at end of file diff --git a/lib/rackup/handler/rage.rb b/lib/rackup/handler/rage.rb new file mode 100644 index 00000000..dfcba731 --- /dev/null +++ b/lib/rackup/handler/rage.rb @@ -0,0 +1 @@ +require "rage" \ No newline at end of file diff --git a/lib/rage-rb.rb b/lib/rage-rb.rb index 2f8d1537..8dcb674f 100644 --- a/lib/rage-rb.rb +++ b/lib/rage-rb.rb @@ -200,3 +200,10 @@ module RageController require_relative "rage/env" require_relative "rage/internal" +require_relative "rage/handler" + +begin + ::Rack::Handler.register("rage", "Rage::Handler") if defined?(::Rack::Handler) + ::Rackup::Handler.register("rage", "Rage::Handler") if defined?(::Rackup::Handler) +rescue StandardError +end diff --git a/lib/rage/handler.rb b/lib/rage/handler.rb new file mode 100644 index 00000000..fd84d7b5 --- /dev/null +++ b/lib/rage/handler.rb @@ -0,0 +1,11 @@ +module Rage + module Handler + def self.run(app, options = {}) + Rage::CLI.new([], { + port: options[:Port], + binding: options[:Host], + environment: options[:environment] + }).server + end + end +end From 4f3433247d3ab7279c659c38dbf66d57171542bb Mon Sep 17 00:00:00 2001 From: pratyush07-hub Date: Thu, 9 Apr 2026 18:37:44 +0530 Subject: [PATCH 2/5] Add changelog entry and fix code style issues --- CHANGELOG.md | 2 ++ lib/rack/handler/rage.rb | 2 +- lib/rackup/handler/rage.rb | 2 +- lib/rage-rb.rb | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90c2b863..84ca1188 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ ## [Unreleased] +### Added +- Support launching with `rackup` on Rack 3 by [@pratyush07-hub](https://github.com/pratyush07-hub) (#259). ## [1.22.1] - 2026-04-01 diff --git a/lib/rack/handler/rage.rb b/lib/rack/handler/rage.rb index dfcba731..c34973a2 100644 --- a/lib/rack/handler/rage.rb +++ b/lib/rack/handler/rage.rb @@ -1 +1 @@ -require "rage" \ No newline at end of file +require "rage" diff --git a/lib/rackup/handler/rage.rb b/lib/rackup/handler/rage.rb index dfcba731..c34973a2 100644 --- a/lib/rackup/handler/rage.rb +++ b/lib/rackup/handler/rage.rb @@ -1 +1 @@ -require "rage" \ No newline at end of file +require "rage" diff --git a/lib/rage-rb.rb b/lib/rage-rb.rb index 8dcb674f..dddf731c 100644 --- a/lib/rage-rb.rb +++ b/lib/rage-rb.rb @@ -205,5 +205,5 @@ module RageController begin ::Rack::Handler.register("rage", "Rage::Handler") if defined?(::Rack::Handler) ::Rackup::Handler.register("rage", "Rage::Handler") if defined?(::Rackup::Handler) -rescue StandardError +rescue end From 7fdc24ce3e53b98b2dbf18cddbb8debe6625f371 Mon Sep 17 00:00:00 2001 From: pratyush07-hub Date: Thu, 9 Apr 2026 20:35:48 +0530 Subject: [PATCH 3/5] Implement production-grade Rack 3 support with environment mapping and middleware integration --- lib/rage-rb.rb | 6 +++++- lib/rage/cli.rb | 6 +++--- lib/rage/handler.rb | 14 +++++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/rage-rb.rb b/lib/rage-rb.rb index dddf731c..a1edac2a 100644 --- a/lib/rage-rb.rb +++ b/lib/rage-rb.rb @@ -7,8 +7,12 @@ module Rage # Builds the Rage application with the configured middlewares. + def self.application=(app) + @application = app + end + def self.application - with_middlewares(Application.new(__router), config.middleware.middlewares) + @application ||= with_middlewares(Application.new(__router), config.middleware.middlewares) end # Builds the Rage application which delegates Rails requests to `Rails.application`. diff --git a/lib/rage/cli.rb b/lib/rage/cli.rb index 40b73ebe..b1d3bda8 100644 --- a/lib/rage/cli.rb +++ b/lib/rage/cli.rb @@ -83,12 +83,12 @@ def new(path = nil) option :binding, aliases: "-b", desc: "Binds Rails to the specified IP - defaults to 'localhost' in development and '0.0.0.0' in other environments" option :config, aliases: "-c", desc: "Uses a custom rack configuration" option :help, aliases: "-h", desc: "Show this message" - def server + def server(app: nil) return help("server") if options.help? set_env(options) - - app = ::Rack::Builder.parse_file(options[:config] || "config.ru") + Rage.configure { config.log_level = :error } if options[:quiet] + app ||= ::Rack::Builder.parse_file(options[:config] || "config.ru") app = app[0] if app.is_a?(Array) server_options = { service: :http, handler: app } diff --git a/lib/rage/handler.rb b/lib/rage/handler.rb index fd84d7b5..c336c40a 100644 --- a/lib/rage/handler.rb +++ b/lib/rage/handler.rb @@ -1,11 +1,15 @@ module Rage module Handler def self.run(app, options = {}) - Rage::CLI.new([], { - port: options[:Port], - binding: options[:Host], - environment: options[:environment] - }).server + Rage.application = app + + cli_options = {} + cli_options[:port] = options[:Port] if options[:Port] + cli_options[:binding] = options[:Host] if options[:Host] + cli_options[:environment] = options[:environment] if options[:environment] + cli_options[:quiet] = options[:quiet] if options[:quiet] + + Rage::CLI.new([], cli_options).server(app: app) end end end From 3ff9b4b75e1976e41513233f95727ac6ca07acac Mon Sep 17 00:00:00 2001 From: pratyush07-hub Date: Thu, 9 Apr 2026 20:40:24 +0530 Subject: [PATCH 4/5] Fix code style in Rage::Handler --- lib/rage/handler.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rage/handler.rb b/lib/rage/handler.rb index c336c40a..1e98dd74 100644 --- a/lib/rage/handler.rb +++ b/lib/rage/handler.rb @@ -2,7 +2,7 @@ module Rage module Handler def self.run(app, options = {}) Rage.application = app - + cli_options = {} cli_options[:port] = options[:Port] if options[:Port] cli_options[:binding] = options[:Host] if options[:Host] From 18a36fc6b24a5891b990a719505b37de176020e4 Mon Sep 17 00:00:00 2001 From: pratyush07-hub Date: Tue, 14 Apr 2026 19:28:04 +0530 Subject: [PATCH 5/5] Fix NoMethodError: name for nil in Rage::Handler discovery --- lib/rack/handler/rage.rb | 1 + lib/rackup/handler/rage.rb | 1 + lib/rage/handler.rb | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/lib/rack/handler/rage.rb b/lib/rack/handler/rage.rb index c34973a2..37c74ba7 100644 --- a/lib/rack/handler/rage.rb +++ b/lib/rack/handler/rage.rb @@ -1 +1,2 @@ require "rage" +Rack::Handler.register("rage", "Rage::Handler") if defined?(Rack::Handler) diff --git a/lib/rackup/handler/rage.rb b/lib/rackup/handler/rage.rb index c34973a2..9a73cf5d 100644 --- a/lib/rackup/handler/rage.rb +++ b/lib/rackup/handler/rage.rb @@ -1 +1,2 @@ require "rage" +Rackup::Handler.register("rage", "Rage::Handler") if defined?(Rackup::Handler) diff --git a/lib/rage/handler.rb b/lib/rage/handler.rb index 1e98dd74..60207fe4 100644 --- a/lib/rage/handler.rb +++ b/lib/rage/handler.rb @@ -1,5 +1,9 @@ module Rage module Handler + def self.name + "Rage" + end + def self.run(app, options = {}) Rage.application = app