Skip to content

Instantly share code, notes, and snippets.

@lihanli
Created August 1, 2012 16:34
Show Gist options
  • Save lihanli/3228539 to your computer and use it in GitHub Desktop.
Save lihanli/3228539 to your computer and use it in GitHub Desktop.
unicorn upstart script
#!/bin/bash
set -u
set -e
APP_NAME='myapp'
APP_ROOT="/home/ubuntu/$APP_NAME"
PID="$APP_ROOT/tmp/pids/unicorn.pid"
ENV=production
GEM_HOME="/home/ubuntu/.rvm/gems/ruby-1.9.3-p194"
UNICORN_OPTS="-E $ENV -c $APP_ROOT/config/unicorn.rb -D"
SET_PATH="cd $APP_ROOT; rvm use 1.9.3-p194; export GEM_HOME=$GEM_HOME"
CMD="$SET_PATH; bundle exec unicorn_rails $UNICORN_OPTS"
su - ubuntu -c "$CMD";
description "unicorn"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on runlevel [016]
console output
exec /home/ubuntu/scripts/init_unicorn.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment