Skip to content

Instantly share code, notes, and snippets.

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

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

  • Foreman's port precedence is -p option, .env file, PORT variable, default of 5000
  • Honcho's port precedence is .env file, PORT variable, -p option, default of 5000
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
honcho start
echo
echo 'Using -p option (expected: 6000)'
foreman start -p 6000
honcho start -p 6000
echo
echo 'Using .env file (expected: 7000)'
echo 'PORT=7000' > .env
foreman start
honcho start
rm .env
echo
echo 'Using PORT variable (expected: 8000)'
export PORT=8000
foreman start
honcho start
unset PORT
echo
echo 'Using -p option and .env file (expected: 6000)'
echo 'PORT=7000' > .env
foreman start -p 6000
honcho start -p 6000
rm .env
echo
echo 'Using -p option and PORT variable (expected: 6000)'
export PORT=8000
foreman start -p 6000
honcho start -p 6000
unset PORT
echo
echo 'Using .env file and PORT variable (expected: 7000)'
echo 'PORT=7000' > .env
export PORT=8000
foreman start
honcho 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
honcho 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