remove load_env! as it's made unnecessary by foreman run
This commit is contained in:
1 parent
cf5689a77a
commit
62c9d1db45
3 files changed
+23
-62
No files matched your search
@@ -4,12 +4,6 @@ module Foreman
|
||||
|
||||
class AppDoesNotExist < Exception; end
|
||||
|
||||
# load contents of env_file into ENV
|
||||
def self.load_env!(env_file = './.env')
|
||||
require 'foreman/engine'
|
||||
Foreman::Engine.load_env!(env_file)
|
||||
end
|
||||
|
||||
def self.runner
|
||||
File.expand_path("../../bin/foreman-runner", __FILE__)
|
||||
end
|
||||
|
||||
+23
-38
@@ -10,6 +10,7 @@ require "thread"
|
||||
|
||||
class Foreman::Engine
|
||||
|
||||
attr_reader :environment
|
||||
attr_reader :procfile
|
||||
attr_reader :directory
|
||||
attr_reader :options
|
||||
@@ -28,11 +29,6 @@ class Foreman::Engine
|
||||
@output_mutex = Mutex.new
|
||||
end
|
||||
|
||||
def self.load_env!(env_file)
|
||||
@environment = read_environment_files(env_file)
|
||||
apply_environment!
|
||||
end
|
||||
|
||||
def start
|
||||
proctitle "ruby: foreman master"
|
||||
termtitle "#{File.basename(@directory)} - foreman"
|
||||
@@ -52,6 +48,10 @@ class Foreman::Engine
|
||||
base_port.to_i + offset + num - 1
|
||||
end
|
||||
|
||||
def apply_environment!
|
||||
environment.each { |k,v| ENV[k] = v }
|
||||
end
|
||||
|
||||
private ######################################################################
|
||||
|
||||
def spawn_processes
|
||||
@@ -198,42 +198,27 @@ private ######################################################################
|
||||
COLORS[@current_color]
|
||||
end
|
||||
|
||||
module Env
|
||||
attr_reader :environment
|
||||
def read_environment_files(filenames)
|
||||
environment = {}
|
||||
|
||||
def read_environment_files(filenames)
|
||||
environment = {}
|
||||
|
||||
(filenames || "").split(",").map(&:strip).each do |filename|
|
||||
error "No such file: #{filename}" unless File.exists?(filename)
|
||||
environment.merge!(read_environment(filename))
|
||||
end
|
||||
|
||||
environment.merge!(read_environment(".env")) unless filenames
|
||||
environment
|
||||
(filenames || "").split(",").map(&:strip).each do |filename|
|
||||
error "No such file: #{filename}" unless File.exists?(filename)
|
||||
environment.merge!(read_environment(filename))
|
||||
end
|
||||
|
||||
def read_environment(filename)
|
||||
return {} unless File.exists?(filename)
|
||||
|
||||
File.read(filename).split("\n").inject({}) do |hash, line|
|
||||
if line =~ /\A([A-Za-z_0-9]+)=(.*)\z/
|
||||
hash[$1] = $2
|
||||
end
|
||||
hash
|
||||
end
|
||||
end
|
||||
|
||||
def apply_environment!
|
||||
@environment.each { |k,v| ENV[k] = v }
|
||||
end
|
||||
|
||||
def error(message)
|
||||
puts "ERROR: #{message}"
|
||||
exit 1
|
||||
end
|
||||
environment.merge!(read_environment(".env")) unless filenames
|
||||
environment
|
||||
end
|
||||
|
||||
include Env
|
||||
extend Env
|
||||
def read_environment(filename)
|
||||
return {} unless File.exists?(filename)
|
||||
|
||||
if line =~ /\A([A-Za-z_0-9]+)=(.*)\z/
|
||||
hash[$1] = $2
|
||||
File.read(filename).split("\n").inject({}) do |hash, line|
|
||||
end
|
||||
end
|
||||
hash
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user