Skip to content

Instantly share code, notes, and snippets.

@krazylegz
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save krazylegz/a673c85cad2be3cbdc50 to your computer and use it in GitHub Desktop.

Select an option

Save krazylegz/a673c85cad2be3cbdc50 to your computer and use it in GitHub Desktop.
# Unicorn - Unicorn job file
description "Unicorn"
author "Vikram Dighe <[email protected]>"
# When to start the service
start on started networking
# When to stop the service
stop on stopping networking
# Automatically restart process if crashed
respawn
# Output should go to the bitbucket
console none
# Set up the environment first
env HOME=/var/www/vhosts/domain.tld/
chdir /var/www/vhosts/domain.tld/current/
# Start the process
script
RVM_EXEC_PATH=/var/www/vhosts/domain.tld/.rvm/bin/rvm-shell
if [ -f "$RVM_EXEC_PATH" ]; then
exec su -s /bin/sh -c 'exec "$0" "$@"' unicorn_user -- $RVM_EXEC_PATH 'ruby-2.1.1' -c 'bundle exec unicorn -p 3999 -o 127.0.0.1 -E production'
else
exec su -s /bin/sh -c 'exec "$0" "$@"' unicorn_user -- bundle exec unicorn -p 3999 -o 127.0.0.1 -E production
fi
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment