Skip to content

Instantly share code, notes, and snippets.

@joeyespo
Last active August 29, 2015 14:11
Show Gist options
  • Save joeyespo/9e8a47f526c27e6abbab to your computer and use it in GitHub Desktop.
Save joeyespo/9e8a47f526c27e6abbab to your computer and use it in GitHub Desktop.
Foreman and Forego port precedence tests

This gist tests and demonstrates the differences between Foreman and Forego's port behavior.

  • Foreman's port precedence is -p option, .env file, PORT variable, default of 5000
  • Forego's port precedence is PORT variable, -p option, default of 5000

Forego completely ignores the PORT variable in .env, which could actually be classified as a completely different issue.

import os
print os.environ.get('PORT', 'PORT not set')
web: python -u app.py
#!/bin/bash
# Ports used
# 5000 - default
# 6000 - -p option
# 7000 - .env file
# 8000 - PORT variable
echo 'Testing defaults (expected: 5000)'
foreman start
forego start
echo
echo 'Using -p option (expected: 6000)'
foreman start -p 6000
forego start -p 6000
echo
echo 'Using .env file (expected: 7000)'
echo 'PORT=7000' > .env
foreman start
forego start
rm .env
echo
echo 'Using PORT variable (expected: 8000)'
export PORT=8000
foreman start
forego start
unset PORT
echo
echo 'Using -p option and .env file (expected: 6000)'
echo 'PORT=7000' > .env
foreman start -p 6000
forego start -p 6000
rm .env
echo
echo 'Using -p option and PORT variable (expected: 6000)'
export PORT=8000
foreman start -p 6000
forego start -p 6000
unset PORT
echo
echo 'Using .env file and PORT variable (expected: 7000)'
echo 'PORT=7000' > .env
export PORT=8000
foreman start
forego start
unset PORT
rm .env
echo
echo 'Using -p option, .env file, and PORT variable (expected: 6000)'
echo 'PORT=7000' > .env
export PORT=8000
foreman start -p 6000
forego start -p 6000
unset PORT
rm .env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment