Use another Procfile in development and production

I have a Sinatra home app for which I intend to use Heroku to host it.

I use a wizard and a 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 fact is, I don’t want to use a shotgun in production , because it is too slow.

Can we use separate procfile configurations for dev and prod?

+56
heroku rack sinatra foreman shotgun
Jul 21 2018-12-21T00:
source share
4 answers

You can use two Procfiles (for example, Procfile and Procfile.dev ) and use the foreman -f option to select another for use in dev:

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

 foreman start -f Procfile.dev 

During production, foreman start will raise a normal Procfile .

Alternatively, you can create the bin directory in your application using a script to start the corresponding web server depending on $RACK_ENV (an idea I found in the comment of the creator of Foreman , so it's worth considering).

+128
Jul 21 '12 at 20:27
source share

@sharagoz commenting on the selected answer, in my opinion, is the best option, allowing you to still use foreman start without adding additional arguments and without sharing your Procfile for Heroku.

To avoid the -f option to Procfile.dev, you can create a procfile: Procfile.dev with procfile: Procfile.dev in it - Sharagoz

In the root directory of the applications, I created a .foreman file and, as the comment says

.master

 procfile: Procfile.dev 

PROCFILE

 web: bundle exec puma -C config/puma.rb 

Procfile.dev

 web: bundle exec puma -C config/puma.rb webpacker: ./bin/webpack-dev-server 
+3
Oct 18 '18 at 17:26
source share

Here's a way to handle using a single Procfile variable and environment. I use this on Heroku.

Set your environment:

 export WEB_START_COMMAND='node index.js' export WORKER_START_COMMAND='node worker.js' 

Profile:

 web: eval '$WEB_START_COMMAND' worker: eval '$WORKER_START_COMMAND' 

Export another run command to your server environment and dev.

+2
Jun 09 '17 at 23:06 on
source share

According to the docs , foreman no longer needed. You can simply use:

heroku local -f Procfile.dev

0
Apr 04 '19 at 11:18
source share



All Articles