Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the differences between using `rails server` and `rackup`?

The only difference I've noted is that rails server starts the server on port 3000, while rackup starts the server on port 9292.

Are there any other differences?

Are there use cases for one instead of the other?

like image 464
Colin Dean Avatar asked Feb 21 '12 18:02

Colin Dean


People also ask

What is rack server in Rails?

Rack provides a minimal, modular, and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call.

What is config RU in rails?

config.ru is a Rack configuration file ( ru stands for "rackup"). Rack provides a minimal interface between web servers that support Ruby and Ruby frameworks. It's like a Ruby implementation of a CGI which offers a standard protocol for web servers to execute programs.

What does rack based mean?

Rack is a modular interface between web servers and web applications developed in the Ruby programming language. With Rack, application programming interfaces (APIs) for web frameworks and middleware are wrapped into a single method call handling HTTP requests and responses.

What is the requirement for rack based application?

Rack compliant code must have the following three characteristics: It must respond to call. The call method must accept a single argument - This argument is typically called env or environment , and it bundles all of the data about the request.


1 Answers

rails server is the command for starting your server (usually WEBrick) and is in rails.

rackup is a command that comes with the rack middle and uses the settings in your config.ru and starts a server based off of those. This is a standard (it will work for other frameworks and rack-based applications) and is usually used in production servers.

One difference of note is that if you start a server with rails s then you will see the output in the terminal.

In my experience, in production, rackup is used by phusion passenger so you wouldn't want rails s in that situation.

As an aside, the port can be changed with both rails server and rackup using the -p flag.

like image 157
Gazler Avatar answered Oct 06 '22 09:10

Gazler