Init Scripts with Thin, Bundler and Monit
October 15th 2010#!/bin/bash
LANG=en_US.UTF-8 \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
BUNDLE_GEMFILE=/u/apps/my_app/current/Gemfile \
/usr/local/bin/bundle exec thin ${1:-start} -C /u/apps/my_app/shared/thin_conf.yml -O
You will thank me later, for sparing you much pain.
Some discussion:
LANG is used to set the language in the shell. This is necessary because Ruby looks at this variable to decide which language it should normally use. This is important because the Locale code for ActiveRecord has a bunch of UTF-8 Characters in it.
PATH is important because when monit starts up a shell, it’s basically like doing
env -i
BUNDLE_GEMFILE points to our gemfile.
Then we start our process with thin.