27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/config_o_mat/configurator/op/generate_all_templates.rb', line 27
def call
error applying_profile.name, applying_profile.errors if applying_profile&.errors?
return if errors?
profiles = applied_profiles
profiles[applying_profile.name] = applying_profile if applying_profile
self.services_to_reload = []
template_defs.each do |(key, templ_def)|
compiled_template = compiled_templates[key]
begin
rendered = compiled_template.render(profiles)
rescue StandardError => e
error key, e
next
end
generated = GeneratedTemplate.new(rendered)
if generated_templates[key] != generated
destination_file = File.join(runtime_directory, templ_def.dst)
logger&.notice(:template_update, template: key, file: destination_file, digest: generated.digest)
generated_templates[key] = generated
File.open(destination_file, 'w') { |f| f.write(rendered) }
dependencies[key]&.each { |service| services_to_reload << service }
end
end
services_to_reload.uniq!
logger&.notice(:scheduled_restarts, services: services_to_reload)
end
|