-
Notifications
You must be signed in to change notification settings - Fork 4
/
passenger.rake
21 lines (19 loc) · 916 Bytes
/
passenger.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
namespace :passenger do
desc 'Generate passenger environment'
task :env => :environment do
ruby_api_version = RbConfig::CONFIG['ruby_version']
passenger_root = Bundler.with_clean_env { `passenger-config --root 2>/dev/null` }.strip
raise "Passenger root not found" unless File.exist?(passenger_root)
env = []
env << %{PATH="/opt/rubies/#{RUBY_VERSION}/bin:/usr/local/bin:/usr/bin"}
env << %{PASSENGER_ROOT="#{passenger_root}"}
env << %{GEM_HOME="/opt/rubies/#{RUBY_VERSION}/lib/ruby/gems/#{ruby_api_version}"}
env << %{GEM_PATH="/opt/rubies/#{RUBY_VERSION}/lib/ruby/gems/#{ruby_api_version}"}
env << %{PASSENGER_OPTS="#{ENV['PASSENGER_OPTS']}"}
file = Rails.root.join('config', 'passenger.env')
file.open('w') { |f| f << env.join("\n") << "\n" }
puts "\nGenerated passenger environment in #{file}:\n\n"
env.each { |l| puts " #{l}" }
puts
end
end