Search code examples
herokusinatrarackforemanshotgun

Foreman: Use different Procfile in development and production


I have a homemade Sinatra application for which I intend to use Heroku to host it.

I use foreman and shotgun in development, with the following Procfile:

web: shotgun config.ru -s thin -o 0.0.0.0 -p $PORT -E $RACK_ENV

It works great with both development and production. But the thing is, I don't want to use shotgun in production since it's too slow.

Can we use separate Procfile configurations for both dev and prod?


Solution

  • Use multiple Procfiles and specify -f or --procfile running option to select one:

    In dev (Procfile.dev contains your shotgun web process):

    foreman start -f Procfile.dev
    

    In production, foreman start will pick up the normal Procfile.

    Alternatively, you could create a bin directory in your app with a script to start the appropriate web server depending on $RACK_ENV (an idea I found in a comment made by the creator of Foreman, so worth considering).