{"record":{"id":"b4fa069cfb096bca","repo":"AdguardTeam/AdGuardHome","slug":"initializing-service-manager-w","errorCode":null,"errorMessage":"initializing service manager: %w","messagePattern":"initializing service manager: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/home/service.go","lineNumber":131,"sourceCode":"\n\ts, err := service.New(p, svcConfig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"initializing service: %w\", err)\n\t}\n\n\treturn s.Run()\n}\n\n// restartService restarts the service.  It returns error if the service is not\n// running.  l must not be nil.\nfunc restartService(ctx context.Context, baseLogger *slog.Logger) (err error) {\n\tsvcMgr, err := ossvc.NewManager(ctx, &ossvc.ManagerConfig{\n\t\tClock:              timeutil.SystemClock{},\n\t\tLogger:             baseLogger.With(slogutil.KeyPrefix, svcLogPrefix),\n\t\tCommandConstructor: executil.SystemCommandConstructor{},\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"initializing service manager: %w\", err)\n\t}\n\n\tact := &ossvc.ActionRestart{\n\t\tServiceName: serviceName,\n\t}\n\n\terr = svcMgr.Perform(ctx, act)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"restarting service: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// handleServiceControlAction one of the possible control actions:\n//\n//   - install:  Installs a service/daemon.\n//   - uninstall:  Uninstalls it.","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/home/service.go#L113-L149","documentation":"During a self-restart after a command-line update (cmdlineUpdate), AdGuard Home failed to construct the OS service manager (ossvc.NewManager) needed to perform the restart action.","triggerScenarios":"cmdlineUpdate calling restartService when NewManager cannot detect a usable service system (no systemd/svc support on this platform) or the manager config is rejected.","commonSituations":"Running an in-place CLI update inside a container without an init system, or on platforms where service control isn't compiled in/supported.","solutions":["Check the wrapped cause; if unsupported platform, restart the process manually (or the container) after the update","Run AdGuard Home as a proper system service so the manager can find it","For containers, restart via orchestrator policy instead of the built-in updater"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Detect a usable service system before attempting updates:\nif !service.Available() { /* manual restart path */ }","typeGuard":null,"tryCatchPattern":"if err := restartService(...); err != nil {\n    // plan a manual restart: log instruction and exit non-zero\n}","preventionTips":["In containers, disable in-place updates or use image-based updates","Run as a system service when using the built-in updater"],"tags":["go","service","restart","update","service-manager"],"backgroundTag":"service-initialization-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}