mirror of
https://github.com/flipped-aurora/gin-vue-admin.git
synced 2026-09-23 21:08:09 +00:00
* feat: mcp能力调整为 streamhttp的独立服务 不再依赖gva本体 * feat: 增加MCP启动能力,增加AI工作流需求整理能力。 * feat: 增加需求梳理能力 * feat: 清理无用日志 * feat: 移除无用的Dify Chatflow文本和代码生成器按钮
59 lines
947 B
Go
59 lines
947 B
Go
//go:build windows
|
|
|
|
package mcpTool
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"os/exec"
|
|
"syscall"
|
|
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
const windowsStillActive = 259
|
|
|
|
func prepareDetachedProcess(cmd *exec.Cmd) {
|
|
cmd.SysProcAttr = &syscall.SysProcAttr{
|
|
HideWindow: true,
|
|
CreationFlags: 0x00000008 | 0x00000200 | 0x08000000,
|
|
}
|
|
}
|
|
|
|
func processExists(pid int) bool {
|
|
if pid <= 0 {
|
|
return false
|
|
}
|
|
|
|
handle, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid))
|
|
if err != nil {
|
|
return false
|
|
}
|
|
defer windows.CloseHandle(handle)
|
|
|
|
var code uint32
|
|
if err := windows.GetExitCodeProcess(handle, &code); err != nil {
|
|
return false
|
|
}
|
|
|
|
return code == windowsStillActive
|
|
}
|
|
|
|
func terminateProcess(pid int) error {
|
|
if pid <= 0 {
|
|
return nil
|
|
}
|
|
|
|
process, err := os.FindProcess(pid)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = process.Kill()
|
|
if err == nil || errors.Is(err, os.ErrProcessDone) {
|
|
return nil
|
|
}
|
|
|
|
return err
|
|
}
|