{"record":{"id":"a148f1168ffcd45c","repo":"multica-ai/multica","slug":"start-or-restart-daemon-w","errorCode":null,"errorMessage":"start or restart daemon: %w","messagePattern":"start or restart daemon: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_setup.go","lineNumber":176,"sourceCode":"\t}\n\n\tif err := cli.SaveCLIConfigForProfile(cfg, profile); err != nil {\n\t\treturn fmt.Errorf(\"save config: %w\", err)\n\t}\n\n\tfmt.Fprintln(os.Stderr, \"Configured for Multica Cloud (https://multica.ai).\")\n\tfmt.Fprintf(os.Stderr, \"  server_url: %s\\n\", cfg.ServerURL)\n\tfmt.Fprintf(os.Stderr, \"  app_url:    %s\\n\", cfg.AppURL)\n\tprintConfigLocation(profile)\n\n\t// Authenticate.\n\tfmt.Fprintln(os.Stderr, \"\")\n\tif err := runLogin(cmd, args); err != nil {\n\t\treturn err\n\t}\n\n\tif err := runDaemonAfterSetup(cmd, args); err != nil {\n\t\treturn fmt.Errorf(\"start or restart daemon: %w\", err)\n\t}\n\tfmt.Fprintln(os.Stderr, \"\\n✓ Setup complete! Your machine is now connected to Multica.\")\n\n\treturn nil\n}\n\nfunc runSetupSelfHost(cmd *cobra.Command, args []string) error {\n\tif err := requireHumanLocalCommand(\"setup\"); err != nil {\n\t\treturn err\n\t}\n\tprofile := resolveProfile(cmd)\n\n\t// Resolve the target URLs before confirming the overwrite so the prompt can\n\t// show the incoming values (\"old -> new\"), making it clear the passed flags\n\t// were received.\n\t//\n\t// Honor MULTICA_SERVER_URL / MULTICA_APP_URL when the matching flag is not\n\t// set — consistent with the rest of the CLI (resolveServerURL) and with the","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_setup.go#L158-L194","documentation":"Returned by the cloud setup flow when runDaemonAfterSetup fails to start or restart the daemon after successful config save and login. The daemon reads server URL and token only at startup, so despite the config being correct, the machine is not yet connected until a daemon runs. The wrapped error carries the daemon command's failure (launch error, health check timeout, or active-task refusal).","triggerScenarios":"`multica setup` completes login, then the daemon binary cannot be spawned, the daemon crashes on startup, or the restart is refused because the running daemon has active tasks (see the sibling error for that case).","commonSituations":"Daemon socket/port already occupied by a stale process; daemon binary missing from PATH or the overridden runtime profile path; systemd user service conflicts; active tasks running under the old config.","solutions":["Check the wrapped error: if it is the active-tasks message, wait for work to finish and run the suggested `multica daemon restart --profile <P>`.","Run `multica daemon status --profile <P>` to see whether a stale daemon is running; stop it.","Verify the daemon executable resolves: `which multica` and any runtime-profile path override.","Retry `multica daemon start --profile <P>` manually to see the daemon's own startup error, then re-run setup or just the daemon start."],"exampleFix":"# before: stale daemon holding the socket\nmultica daemon stop --profile default || true\n# after\nmultica daemon start --profile default","handlingStrategy":"retry","validationCode":"# Pre-flight: confirm no stale daemon and the binary resolves\nmultica daemon status --profile \"$P\" 2>/dev/null\ncommand -v multica >/dev/null || echo \"multica not on PATH\"","typeGuard":null,"tryCatchPattern":"On 'start or restart daemon:' failure, branch: if the wrapped message contains 'active' tasks → schedule retry after drain; otherwise stop stale daemons and retry once with diagnostics captured.","preventionTips":["Stop daemons before deployment-switching setups.","Keep the daemon binary path stable or update runtime profile overrides deliberately.","In scripts, follow setup with an explicit `multica daemon status` assertion."],"tags":["go","cli","daemon","setup","process-lifecycle"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}