lib/eye/config.rb in reel-eye-0.4.1 vs lib/eye/config.rb in reel-eye-0.5
- old
+ new
@@ -28,37 +28,40 @@
no_pid_file = all_processes.select{|c| c[:pid_file].blank? }
if no_pid_file.present?
raise Eye::Dsl::Error, "blank pid_file for: #{no_pid_file.map{|c| c[:name]} * ', '}"
end
- # Check dublicates of the full pid_file
+ # Check duplicates of the full pid_file
- dubl_pids = all_processes.each_with_object(Hash.new(0)) do |o, h|
+ dupl_pids = all_processes.each_with_object(Hash.new(0)) do |o, h|
ex_pid_file = Eye::System.normalized_file(o[:pid_file], o[:working_dir])
h[ex_pid_file] += 1
end
- dubl_pids = dubl_pids.select{|k,v| v>1}
+ dupl_pids = dupl_pids.select{|k,v| v>1}
- if dubl_pids.present?
- raise Eye::Dsl::Error, "dublicate pid_files: #{dubl_pids.inspect}"
+ if dupl_pids.present?
+ raise Eye::Dsl::Error, "duplicate pid_files: #{dupl_pids.inspect}"
end
- # Check dublicates of the full_name
- dubl_names = all_processes.each_with_object(Hash.new(0)) do |o, h|
+ # Check duplicates of the full_name
+ dupl_names = all_processes.each_with_object(Hash.new(0)) do |o, h|
full_name = "#{o[:application]}:#{o[:group]}:#{o[:name]}"
h[full_name] += 1
end
- dubl_names = dubl_names.select{|k,v| v>1}
+ dupl_names = dupl_names.select{|k,v| v>1}
- if dubl_names.present?
- raise Eye::Dsl::Error, "dublicate names: #{dubl_names.inspect}"
+ if dupl_names.present?
+ raise Eye::Dsl::Error, "duplicate names: #{dupl_names.inspect}"
end
# validate processes with their own validate
all_processes.each do |process_cfg|
Eye::Process.validate process_cfg
end
+
+ # just to be sure ENV was not removed
+ ENV[''] rescue raise Eye::Dsl::Error.new("ENV is not a hash '#{ENV.inspect}'")
end
def processes
applications.values.map{|e| (e[:groups] || {}).values.map{|c| (c[:processes] || {}).values} }.flatten
end
@@ -71,18 +74,18 @@
applications.delete(name)
end
def delete_group(name)
applications.each do |app_name, app_cfg|
- app_cfg[:groups].delete(name)
+ (app_cfg[:groups] || {}).delete(name)
end
end
def delete_process(name)
applications.each do |app_name, app_cfg|
- app_cfg[:groups].each do |gr_name, gr_cfg|
- gr_cfg[:processes].delete(name)
+ (app_cfg[:groups] || {}).each do |gr_name, gr_cfg|
+ (gr_cfg[:processes] || {}).delete(name)
end
end
end
-end
\ No newline at end of file
+end