Created
December 20, 2011 16:01
-
-
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
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
#! /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! |
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
#! /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