Skip to content

Instantly share code, notes, and snippets.

@stevenharman
Last active December 21, 2015 04:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenharman/6250650 to your computer and use it in GitHub Desktop.
Save stevenharman/6250650 to your computer and use it in GitHub Desktop.
A wrapper script that will start a local SSH tunnel (only in development environment), and then start Puma as normal. I use this with foreman from a Procfile.
#!/usr/bin/env sh
CURRENT_ENV=${RACK_ENV:-development}
# For the payment gateway callback URL
if [ "$CURRENT_ENV" == "development" ]; then
PORT_SSL=$(expr $PORT + 1)
echo "starting an SSL tunnel from :$PORT_SSL --(--)--> :$PORT"
bundle exec tunnels $PORT_SSL 0.0.0.0:$PORT &
fi
bundle exec puma -b tcp://0.0.0.0:$PORT -t 0:${WEB_CONCURRENCY:-16} -e $CURRENT_ENV
# USAGE:
# from a Procfile (bundler) you'd use this as
# web: bin/puma
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment