Skip to content

Instantly share code, notes, and snippets.

@jmervine
Last active October 11, 2015 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmervine/3928518 to your computer and use it in GitHub Desktop.
Save jmervine/3928518 to your computer and use it in GitHub Desktop.
thin wrapper
# Directory pathing context should be that of the thin
# init script sourcing this file, not this file itself.
#
# allow for overides as such
#
test "$RACK_ENV" || RACK_ENV="production"
test "$THIN_PORT" || THIN_PORT="4321"
test "$THIN_PID" || THIN_PID="./log/listener.pid"
test "$THIN_LOG" || THIN_LOG="./log/listener.log"
test "$THIN_ADDY" || THIN_ADDY="0.0.0.0"
# force defaults as such
#
#RACK_ENV="development"
#THIN_PORT="4321"
#THIN_PID="./log/listener.pid"
#THIN_LOG="./log/listener.log"
# vim: set filetype=sh
#!/usr/bin/env bash
# source config if present
test -f ./config/thinrc && source ./config/thinrc
# set up primary defaults
test "$RACK_ENV" || RACK_ENV="production"
test "$THIN_PORT" || THIN_PORT="8000"
test "$THIN_PID" || THIN_PID="./log/packages.pid"
test "$THIN_LOG" || THIN_LOG="./log/packages.log"
DAEMONIZE="--log $THIN_LOG --daemonize"
test "$DEVELOP" && DAEMONIZE=""
test "$DEBUG" && set -x
if ! test "$1"
then
echo "Usage: listener start|stop|restart"
echo " "
echo "Takes the following overides as environemnt variables:"
echo " "
echo " RACK_ENV :: default $RACK_ENV"
echo " THIN_PORT :: default $THIN_PORT"
echo " THIN_PID :: default $THIN_PID"
echo " THIN_LOG :: default $THIN_LOG"
echo " "
echo "Takes config file as './config/thinrc' with overides above. "
echo " "
exit 0
fi
RACK_ENV=$RACK_ENV bundle exec thin --port $THIN_PORT --pid $THIN_PID $DAEMONIZE $1
# vim: set filetype=sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment