Skip to content

Instantly share code, notes, and snippets.

@rdj
Created September 8, 2011 21:18
Show Gist options
  • Select an option

  • Save rdj/1204763 to your computer and use it in GitHub Desktop.

Select an option

Save rdj/1204763 to your computer and use it in GitHub Desktop.
# Restart unicorn through RVM to allow for ruby interpreter version upgrades
rvm_shell = '/home/deploy/.rvm/bin/rvm-shell'
unicorn_args = Unicorn::HttpServer::START_CTX[:argv].join(' ')
shell_args = [ '-c', "cd /u/apps/innerfence/current && exec bundle exec unicorn #{unicorn_args}" ]
Unicorn::HttpServer::START_CTX[0] = rvm_shell
Unicorn::HttpServer::START_CTX[:argv] = shell_args
# Scrub the environment
before_exec do |server|
ENV.delete_if { |k| k.starts_with? 'BUNDLE' }
ENV.delete_if { |k| k.starts_with? 'GEM' }
ENV.delete_if { |k| k.starts_with? 'RUBY' }
ENV.delete_if { |k| k.starts_with? 'rvm' }
ENV.delete 'IRBRC'
ENV.delete 'MY_RUBY_HOME'
ENV['PATH'] = ENV['PATH'].split(/:/).reject{ |p| p =~ /[.]rvm/ }.join(':')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment