hlctl/svcctl/svc.go

23 lines
564 B
Go
Raw Normal View History

2023-01-07 16:56:15 +00:00
package svcctl
import (
"os/exec"
"sectorinf.com/emilis/hlctl/config"
"sectorinf.com/emilis/hlctl/ctllog"
"sectorinf.com/emilis/hlctl/hlcl"
)
var log = ctllog.Logger{}.New("config", ctllog.ColorRGB{}.FromHex("2e8647"))
func RestartServices(cfg config.ServicesConfig) {
for _, svc := range cfg.Services {
log.Printf("Restarting [%s]", svc)
if err := exec.Command("pkill", "-9", svc).Run(); err != nil {
log.Errorf("Killing [%s]: %s", svc, err)
}
if err := hlcl.SilentSpawn(svc); err != nil {
log.Errorf("Starting [%s]: %s", svc, err)
}
}
}