MCPcopy Create free account
hub / github.com/cronitorio/cronitor-cli / getSystemdServiceName

Function getSystemdServiceName

cmd/dash.go:3120–3152  ·  view source on GitHub ↗

getSystemdServiceName attempts to determine the systemd service name

()

Source from the content-addressed store, hash-verified

3118
3119// getSystemdServiceName attempts to determine the systemd service name
3120func getSystemdServiceName() string {
3121 // Try to get service name from systemd environment
3122 if serviceName := os.Getenv("SYSTEMD_SERVICE"); serviceName != "" {
3123 return serviceName
3124 }
3125
3126 // Try common service names based on executable name
3127 executable, err := os.Executable()
3128 if err != nil {
3129 return ""
3130 }
3131
3132 baseName := strings.TrimSuffix(filepath.Base(executable), filepath.Ext(executable))
3133
3134 // Common patterns for systemd service names
3135 possibleNames := []string{
3136 baseName + ".service",
3137 baseName + "-dashboard.service",
3138 "crontab-guru-dashboard.service", // User mentioned this specific name
3139 "cronitor-cli.service",
3140 "cronitor.service",
3141 }
3142
3143 // Check which service exists and is active
3144 for _, name := range possibleNames {
3145 cmd := exec.Command("systemctl", "is-active", "--quiet", name)
3146 if err := cmd.Run(); err == nil {
3147 return name
3148 }
3149 }
3150
3151 return ""
3152}
3153
3154// performManualRestart performs a manual restart (non-systemd)
3155func performManualRestart(sendProgress func(string)) error {

Callers 1

requestSystemdRestartFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected