Skip to content

Instantly share code, notes, and snippets.

@fcoury
Created March 30, 2012 19:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fcoury/2254378 to your computer and use it in GitHub Desktop.
Save fcoury/2254378 to your computer and use it in GitHub Desktop.
Starts foreman when there are multiple Procfiles
#
# zsh function to start Foreman based on whether or not
# you have multiple Procfiles
#
# we are adopting this schema of having environment
# specific Procfiles:
#
# config/development.proc
# config/stage.proc
# config/production.proc
#
# it searches for a config/ENV.proc file first, and
# if not found, falls back to Procfile
#
function fs {
env=${RAILS_ENV:-development}
if [ -f config/$env.proc ]; then
foreman start -d . -f config/$env.proc
else
if [ -f Procfile ]; then
foreman start
else
echo no Procfile, aborting.
fi
fi
}
@fcoury
Copy link
Author

fcoury commented Mar 30, 2012

Another good thing about this is that you can keep the production Procfile on your project root folder and it won't be used when you boot it on your dev environment, for instance.

@jeffrydegrande
Copy link

try this

env=${RAILS_ENV:-development}

@fcoury
Copy link
Author

fcoury commented Mar 30, 2012

@jeffrydegrande
Copy link

couldn't resist ;)


function start_foreman_for_env {
  env=${RAILS_ENV:-development}
  [ -f config/$env.proc ] || return 1
  foreman start -d . -f config/$env.proc
}

function start_foreman {
  [ -f Procfile ] || return 1
  foreman start
}

start_foreman_for_env || start_foreman || echo "No Procfile. aborting"

@fcoury
Copy link
Author

fcoury commented Mar 30, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment