Foreman conditional process with .env file in Rails

I am using foreman gem on my Ruby on Rails application to launch my different processes. In a .env file, I declared some boolean variable to decide if I want to run a process or not.

I want to be able to enable or disabled « maildev », a nodejs application to handle email in local. If the boolean is true it’s working perfectly but if change it to false, foreman crash on startup.

Here is the trace from foreman:

13:20:17 web.1    | started with pid 6583
13:20:17 mailer.1 | started with pid 6584
13:20:17 mailer.1 | ====== Maildev server not launched ======
13:20:17 mailer.1 | exited with code 0
13:20:17 system   | sending SIGTERM to all processes
13:20:17 web.1    | terminated by SIGTERM

my .env file:

RACK_ENV=development
START_MAILDEV=false

my Procfile:

# Rails server
web: bin/procfile/web

# Mail server
mailer: bin/procfile/maildev

bin/procfile/maildev:

#!/bin/sh
if [[ "$RACK_ENV" == 'development' ]]; then
  if [[ "$START_MAILDEV" == "true" ]]; then
    maildev
    echo "====== Maildev server launched ======"
  else
    echo "====== Maildev server not launched ======"
  fi
fi

Does someone know what’s wrong with my code ?
Thanks !

Your code is fine, but when one of your processes exits, which echo does immediately, Foreman shuts down all the rest of them.

Foreman's approved way to run only some processes is with the -c flag.

-c, --concurrency

Specify the number of each process type to run. The value passed in should be in the format process=num,process=num

In your case,

foreman start -c web=1

If you have lots of processes and you want to run them all except for one, there's a special all keyword, and then you can override the one you don't want.

foreman start -c all=1,maildev=0