What is the difference between foreman start and foreman run rails server?

WinkyCharlie picture WinkyCharlie · Jan 15, 2014 · Viewed 12.2k times · Source

I'm new to using the foreman gem on Rails. I'm running an app on Rails 3.2, Ruby 1.9.3 and Foreman 0.6. I would like to know what happens behind the scenes when I run foreman. Specifically, the difference between running foreman run rails s versus foreman start on my local terminal.

I have noticed some differences already. For e.g., a worker runs only when running foreman start and not when I run foreman run rails s. But I would like to know the specifics. Where can read more about this, or can someone explain how it works?

Answer

Jonah picture Jonah · Jan 15, 2014

See http://ddollar.github.io/foreman/

foreman start is used to run your application directly from the command line. If no additional parameters are passed, foreman will run one instance of each type of process defined in your Procfile.

foreman run is used to run one-off commands using the same environment as your defined processes.

run is useful since your app may depend on environment variables defined in a .env file being loaded by foreman and which new to be present even when running a single process. start allows you to run a complex app environment which requires multiple processes to be fully functional (background job processing in addition to a web server for example).