chore: remove serviceName or inline, update service unit description

This commit is contained in:
2025-06-23 17:47:46 -05:00
parent 06e036a116
commit 821067765e
3 changed files with 8 additions and 12 deletions

View File

@@ -15,8 +15,6 @@ import (
"github.com/coreos/go-systemd/daemon"
)
const serviceName = "HATray"
// linuxService implements the Service interface for Linux
// It integrates with systemd and controls the app layer
// according to systemd signals (start, stop, reload)

View File

@@ -14,8 +14,6 @@ import (
"golang.org/x/sys/windows/svc/eventlog"
)
const serviceName = "HATray"
// WindowsService implements the Service interface for Windows
type WindowsService struct {
app *app.App
@@ -43,29 +41,29 @@ func (svc *WindowsService) Run() error {
// Acquire the appropriate run function & eventlog instance depending on service type
if isService {
svc.logger.Debug("running as Windows service", "serviceName", serviceName)
svc.logger.Debug("running as Windows service")
run = winsvc.Run
svc.elog, err = eventlog.Open(serviceName)
svc.elog, err = eventlog.Open("HATray")
if err != nil {
return fmt.Errorf("failed to open event log: %v", err)
}
} else {
svc.logger.Debug("running as debug service", "serviceName", serviceName)
svc.logger.Debug("running as debug service")
run = debug.Run
svc.elog = debug.New(serviceName)
svc.elog = debug.New("HATray")
}
defer svc.elog.Close()
svc.elog.Info(1, fmt.Sprintf("starting %s service", serviceName))
svc.elog.Info(1, "starting service")
// Run the service with our handler
err = run(serviceName, &serviceHandler{
err = run("HATray", &serviceHandler{
service: svc,
})
if err != nil {
svc.elog.Error(1, fmt.Sprintf("%s service failed: %v", serviceName, err))
svc.elog.Error(1, fmt.Sprintf("service failed: %v", err))
return err
}