{"record":{"id":"1e8bd7e66f6ceaa2","repo":"flipped-aurora/gin-vue-admin","slug":"mcp-w-1e8bd7","errorCode":null,"errorMessage":"启动 MCP 独立服务失败: %w","messagePattern":"启动 MCP 独立服务失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/standalone_manager.go","lineNumber":178,"sourceCode":"\t\treturn GetManagedStandaloneStatus(context.Background()), err\n\t}\n\n\tlogPath := filepath.Join(runtimeDir, mcpRuntimeLogName)\n\tlogFile, err := os.OpenFile(logPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o644)\n\tif err != nil {\n\t\treturn GetManagedStandaloneStatus(context.Background()), err\n\t}\n\tdefer logFile.Close()\n\n\tcmd := exec.Command(commandPath, commandArgs...)\n\tcmd.Dir = workDir\n\tcmd.Stdout = logFile\n\tcmd.Stderr = logFile\n\tcmd.Env = append(os.Environ(), \"GVA_MCP_CONFIG=\"+configPath)\n\tprepareDetachedProcess(cmd)\n\n\tif err := cmd.Start(); err != nil {\n\t\treturn GetManagedStandaloneStatus(context.Background()), fmt.Errorf(\"启动 MCP 独立服务失败: %w\", err)\n\t}\n\n\tpid := cmd.Process.Pid\n\t_ = cmd.Process.Release()\n\n\tmeta = &managedProcessMeta{\n\t\tPID:        pid,\n\t\tStartedAt:  time.Now().Format(time.RFC3339),\n\t\tLogPath:    logPath,\n\t\tConfigPath: configPath,\n\t\tWorkDir:    workDir,\n\t\tCommand:    commandPath,\n\t\tArgs:       append([]string{}, commandArgs...),\n\t}\n\tif err := writeManagedProcessMeta(meta); err != nil {\n\t\treturn GetManagedStandaloneStatus(context.Background()), err\n\t}\n","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/standalone_manager.go#L160-L196","documentation":"Thrown by StartManagedStandalone when os/exec's cmd.Start() fails to launch the detached MCP standalone binary process. The command was fully prepared (stdout/stderr to a log file, GVA_MCP_CONFIG env, detached attributes) but the OS refused or failed to spawn it.","triggerScenarios":"cmd.Start() returns error: binary not executable (missing +x), binary arch mismatch, missing dynamic libs, log file not writable, fork/exec failure on the platform, resource limits (too many processes).","commonSituations":"Built binary copied from another OS/arch (e.g. darwin binary on linux); running in a container without exec permission on the volume (noexec mount); log file directory permissions changed; PID/process limits hit.","solutions":["Check the cause in the wrapped error: 'permission denied' -> chmod +x or fix noexec mount; 'exec format error' -> rebuild for the host OS/arch.","Ensure the log file path (meta.LogPath directory) exists and is writable.","Rebuild the binary with the project's build command for the current platform.","Check ulimit/nproc and container security policies if under heavy load or restricted runtime."],"exampleFix":"// check before starting\nif err := os.Chmod(binaryPath, 0o755); err != nil { return err }\nif runtime.GOOS != expectedOS {\n    return fmt.Errorf(\"binary built for %s, host is %s\", expectedOS, runtime.GOOS)\n}\nstatus, err := StartManagedStandalone(ctx)","handlingStrategy":"validation","validationCode":"info, err := os.Stat(binaryPath)\nif err != nil { return err }\nif info.Mode()&0o111 == 0 { return fmt.Errorf(\"%s is not executable\", binaryPath) }\nif runtime.GOOS != buildOS { return fmt.Errorf(\"arch/OS mismatch: built for %s\", buildOS) }","typeGuard":null,"tryCatchPattern":"status, err := StartManagedStandalone(ctx)\nif err != nil {\n    if strings.Contains(err.Error(), \"permission denied\") {\n        os.Chmod(binaryPath, 0o755) // or remount without noexec\n    }\n    return err\n}","preventionTips":["chmod +x the binary right after building/copying it.","Build on the target OS/arch (or use GOOS/GOARCH cross-build correctly).","Never place the binary on a noexec-mounted volume.","Ensure the log directory exists and is writable before starting."],"tags":["process","exec","mcp","spawn-failure"],"backgroundTag":"process-start-failed","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}