lib/foreman/engine.rb in foreman-0.22.0 vs lib/foreman/engine.rb in foreman-0.23.1
- old
+ new
@@ -20,11 +20,11 @@
def initialize(procfile, options={})
@procfile = read_procfile(procfile)
@directory = File.expand_path(File.dirname(procfile))
@options = options
- @environment = read_environment(options[:env])
+ @environment = read_environment_files(options[:env])
end
def processes
@processes ||= begin
@order = []
@@ -200,27 +200,30 @@
puts "!!! This format of Procfile is deprecated, and will not work starting in v0.12"
puts "!!! Use a colon to separate the process name from the command"
puts "!!! e.g. web: thin start"
end
- def read_environment(filename)
- error "No such file: #{filename}" if filename && !File.exists?(filename)
- filename ||= ".env"
+ def read_environment_files(filenames)
environment = {}
- if File.exists?(filename)
- File.read(filename).split("\n").each do |line|
- if line =~ /\A([A-Za-z_]+)=(.*)\z/
- environment[$1] = $2
- end
- end
+ (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
end
- def runner
- File.expand_path("../../../bin/foreman-runner", __FILE__)
+ def read_environment(filename)
+ return {} unless File.exists?(filename)
+
+ File.read(filename).split("\n").inject({}) do |hash, line|
+ if line =~ /\A([A-Za-z_]+)=(.*)\z/
+ hash[$1] = $2
+ end
+ hash
+ end
end
def terminate_gracefully
info "sending SIGTERM to all processes"
kill_all "SIGTERM"