This commit is contained in:
Philippe Caseiro 2022-06-30 09:48:10 +02:00
parent 4479fa02e4
commit 5a75bc5a37
2 changed files with 14 additions and 10 deletions

View File

@ -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) return fmt.Errorf("Process templates failed with error: %v", err)
} }
log.Printf("\tFile %s generated\n", dest) 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 return nil
} }

View File

@ -81,6 +81,7 @@ func processConfigFiles(tpls []ConfigFile, variables map[string]interface{}, tem
return fmt.Errorf("Error unmarshaling values on template process; %v", err) return fmt.Errorf("Error unmarshaling values on template process; %v", err)
} }
var servicesToRestart []string
for _, tpl := range tpls { for _, tpl := range tpls {
fileExt := filepath.Ext(tpl.Source) fileExt := filepath.Ext(tpl.Source)
if fileExt == ".hcl" { 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) 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 return nil
} }