mirror of
https://github.com/Xevion/HATray.git
synced 2025-12-06 01:15:11 -06:00
chore: remove serviceName or inline, update service unit description
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user