{"record":{"id":"100347d542e07282","repo":"AdguardTeam/AdGuardHome","slug":"reloading-service-w","errorCode":null,"errorMessage":"reloading service: %w","messagePattern":"reloading service: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/home/service.go","lineNumber":297,"sourceCode":"\t\tl.InfoContext(ctx, \"running\")\n\tcase ossvc.StatusRestartOnFail:\n\t\tl.InfoContext(ctx, \"restarting after failed start\")\n\t}\n\n\treturn nil\n}\n\n// handleServiceReloadCmd reloads the service, if it's running.  l must not be\n// nil, mgr must be a ReloadManager.\nfunc handleServiceReloadCmd(ctx context.Context, l *slog.Logger, mgr ossvc.Manager) (err error) {\n\trelSvcMgr, ok := mgr.(ossvc.ReloadManager)\n\tif !ok {\n\t\treturn fmt.Errorf(\"service manager can't reload: %w\", errors.ErrUnsupported)\n\t}\n\n\terr = relSvcMgr.Reload(ctx, serviceName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reloading service: %w\", err)\n\t}\n\n\tl.InfoContext(ctx, \"service reloaded successfully\")\n\n\treturn nil\n}\n\n// handleServiceInstallCmd handles the service \"install\" command.  l must\n// not be nil.\nfunc handleServiceInstallCmd(\n\tctx context.Context,\n\tl *slog.Logger,\n\tmgr ossvc.Manager,\n\topts options,\n\tworkDir string,\n\tconfPath string,\n) (err error) {\n\tpwd, err := os.Getwd()","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/home/service.go#L279-L315","documentation":"The service manager's Reload call failed while trying to make the running service re-read its configuration. This wraps whatever error the underlying OS service layer (systemd, launchd, sc.exe, etc.) returned, such as the service not being loaded, insufficient privileges, or a unit file problem.","triggerScenarios":"Calling handleServiceReloadCmd when the service is not running or not installed; reloading without root/admin privileges; a broken or missing service unit/configuration on disk.","commonSituations":"'AdGuardHome -s reload' run as a non-root user; systemd unit in a failed state; service was uninstalled while its definition lingered; config file path changed so the manager can't signal the daemon.","solutions":["Verify the service is actually installed and running before reloading","Re-run the command with root/administrator privileges","Inspect the OS service manager status (systemctl status AdGuardHome / sc query) for the underlying cause","Repair or reinstall the service via the 'install' action"],"exampleFix":"// before\nerr = relSvcMgr.Reload(ctx, serviceName)\nif err != nil {\n\treturn fmt.Errorf(\"reloading service: %w\", err)\n}\n\n// after (caller-side resilience)\nerr = relSvcMgr.Reload(ctx, serviceName)\nif err != nil {\n\tl.WarnContext(ctx, \"reload failed, falling back to restart\", \"error\", err)\n\terr = mgr.Perform(ctx, &ossvc.ActionRestart{ServiceName: serviceName})\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// after\nif err := relSvcMgr.Reload(ctx, serviceName); err != nil {\n    log.Warn(\"reload failed\", \"err\", err)\n    err = mgr.Perform(ctx, &ossvc.ActionRestart{ServiceName: serviceName})\n    if err != nil { return err }\n}","preventionTips":["Run service control commands with root/admin privileges","Verify the service is running before reloading","Automate a restart fallback when reload fails"],"tags":["service-management","reload","privileges"],"backgroundTag":"service-reload-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}