package configure

import (
	sunhpcconf "gitea.sunhpc.com/kelvin/sunhpc/internal/pkg/config"
	"gitea.sunhpc.com/kelvin/sunhpc/internal/pkg/util"
	"gitea.sunhpc.com/kelvin/sunhpc/internal/pkg/splog"
)

func SUNHPCD() (err error) {
	controller := sunhpcconf.Get()
	if controller.Sunhpc.SystemdName != "" {
		splog.Info("Enabling and restarting the Sunhpc server")
		err = util.SystemdStart(controller.Sunhpc.SystemdName)
		if err != nil {
			return err
		}
	} else {
		splog.Warn("Not (re)starting Sunhpc server: no systemd name configured")
	}

	return nil
}
