Created
April 12, 2016 17:34
-
-
Save realmyst/0cf27140da96eb7e66b5bf41e4a0d681 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/etc/init/{{item.app}}.conf | |
description "Unicorn" | |
start on startup | |
console output | |
env NEW_RELIC_APP_NAME={{app_name}} | |
env UNICORN_WORKERS={{unicorn_workers}} | |
env app=/u/apps/{{item.app}}/current | |
env REDIS_URL={{sidekiq_redis[item.app]}} | |
chdir /u/apps/{{item.app}}/current | |
setuid poweruser | |
setgid poweruser | |
respawn | |
#respawn limit 3 30 | |
#instance ${app} | |
script | |
exec /bin/bash <<'EOT' | |
# set HOME to the setuid user's home, there doesn't seem to be a better, portable way | |
export HOME="$(eval echo ~$(id -un))" | |
if [ -d "/usr/local/rbenv/bin" ]; then | |
export PATH="/usr/local/rbenv/bin:/usr/local/rbenv/shims:$PATH" | |
elif [ -d "$HOME/.rbenv/bin" ]; then | |
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH" | |
elif [ -f /etc/profile.d/rvm.sh ]; then | |
source /etc/profile.d/rvm.sh | |
elif [ -f /usr/local/rvm/scripts/rvm ]; then | |
source /etc/profile.d/rvm.sh | |
elif [ -f "$HOME/.rvm/scripts/rvm" ]; then | |
source "$HOME/.rvm/scripts/rvm" | |
elif [ -f /usr/local/share/chruby/chruby.sh ]; then | |
source /usr/local/share/chruby/chruby.sh | |
if [ -f /usr/local/share/chruby/auto.sh ]; then | |
source /usr/local/share/chruby/auto.sh | |
fi | |
# if you aren't using auto, set your version here | |
# chruby 2.0.0 | |
fi | |
cd $app | |
logger -t {{item.app}} "Starting server: $app" | |
exec bundle exec unicorn -c /u/apps/{{item.app}}/current/config/unicorn.rb -E production | |
EOT | |
end script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment