Skip to content

Instantly share code, notes, and snippets.

@ahoward
Created December 20, 2011 16:01
Show Gist options
  • Save ahoward/1502071 to your computer and use it in GitHub Desktop.
Save ahoward/1502071 to your computer and use it in GitHub Desktop.
/usr/bin/ruby # using rbenv to manage a system ruby that's available during init.d
#! /usr/bin/ruby
# file: /etc/init.d/rubyapps
#
#
globs = %w(
/ebs/apps/*/init.rb
/ebs/apps/*/current/init.rb
)
globs.each do |glob|
Dir.glob(glob) do |init_rb|
init_rb = File.expand_path(init_rb)
command = "ruby #{ init_rb.inspect }"
puts(command) if STDOUT.tty?
if fork
next
else
exec(command)
end
end
end
exit!
#! /bin/sh
# file: /usr/bin/ruby
#
# the normal 'rbenv global 1.9.3-p0' will affect this script but, unlike having *only* rbenv, this ruby will be available at low run levels (aka, for init scripts)
export RBENV_ROOT="/usr/local/rbenv"
export PATH="/usr/local/rbenv/bin:/usr/local/rbenv/shims:$PATH"
exec ruby "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment