Merge pull request #1433 from mguillemot/bluepill_env

Bluepill load content of .env file
This commit is contained in:
Robin Ward 2013-09-13 11:11:52 -07:00
commit cca09e1436

View file

@ -14,9 +14,6 @@ Bluepill.application("discourse", :base_dir => ENV["HOME"] + '/.bluepill') do |a
# Running bluepill as root? Use: # Running bluepill as root? Use:
#Bluepill.application("discourse") do |app| #Bluepill.application("discourse") do |app|
app.gid = group
app.uid = user
# getting this to work was a nightmare # getting this to work was a nightmare
# bundle exec spawns a process totally messing with the demonize option # bundle exec spawns a process totally messing with the demonize option
# so we suck the environment out and set it up first # so we suck the environment out and set it up first
@ -39,6 +36,16 @@ Bluepill.application("discourse", :base_dir => ENV["HOME"] + '/.bluepill') do |a
end end
app.environment ||= {} app.environment ||= {}
# Load .env file if there is one
if File.exist? "#{rails_root}/.env"
File.read("#{rails_root}/.env").split("\n").each do |l|
kv = l.chomp.split('=',2)
app.environment[kv[0]] = kv[1]
end
end
# Force RAILS_ENV to the value specified in the environment of the bluepill invocation
app.environment['RAILS_ENV'] = rails_env app.environment['RAILS_ENV'] = rails_env
app.gid = group app.gid = group