The Rack gem ships with the rackup command (update: as of Rack 3, the rackup command has been moved to a separate rackup gem. See this pull-request and related discussion). It is a useful tool for running Rack applications with a web server. It uses the Rack::Builder DSL (domain-specific language) to configure middleware and easily compose applications.

The rackup command automatically figures out the environment it is run in, and runs your application as WEBrick, Puma, or any web server—all from the same configuration.

Let’s try that now.

So far, we’ve been launching our web application using a web server-specific command, i.e. pumathin start, or unicorn. Using rackup lets us be web server agnostic. In the same directory containing your config.ru file, run rackup command.

$ gem install rackup
$ rackup

Puma starting in single mode...
* Puma version: 5.6.4 (ruby 2.7.1-p83) ("Birdie's Version")
*  Min threads: 0
*  Max threads: 5
*  Environment: development
*          PID: 28318
* Listening on http://127.0.0.1:9292
* Listening on http://[::1]:9292
Use Ctrl-C to stop

Since I have Puma installed, it launched the application in Puma. If you have some other web server, rackup will use it.