diff --git a/pkg/templater/files.go b/pkg/templater/files.go index 4385235..cc95268 100644 --- a/pkg/templater/files.go +++ b/pkg/templater/files.go @@ -53,16 +53,6 @@ func (cf *ConfigFile) Generate(root string, templateDir string, values []byte) e return fmt.Errorf("Process templates failed with error: %v", err) } log.Printf("\tFile %s generated\n", dest) - - if cf.Service != "" { - sv := SystemService{ - Name: cf.Service, - Enabled: true, - Type: "", - ToStart: true, - } - return sv.Restart() - } return nil } diff --git a/pkg/templater/services.go b/pkg/templater/services.go index 9a17278..db30e44 100644 --- a/pkg/templater/services.go +++ b/pkg/templater/services.go @@ -81,6 +81,7 @@ func processConfigFiles(tpls []ConfigFile, variables map[string]interface{}, tem return fmt.Errorf("Error unmarshaling values on template process; %v", err) } + var servicesToRestart []string for _, tpl := range tpls { fileExt := filepath.Ext(tpl.Source) if fileExt == ".hcl" { @@ -94,6 +95,19 @@ func processConfigFiles(tpls []ConfigFile, variables map[string]interface{}, tem return fmt.Errorf("Template %s generation failed with error %v", tpl.Source, err) } + if len(tpl.Service) != 0 { + servicesToRestart = append(servicesToRestart, tpl.Service) + } + } + + for _, srv := range servicesToRestart { + sv := SystemService{ + Name: srv, + Enabled: true, + Type: "", + ToStart: true, + } + return sv.Restart() } return nil }