mirror of
https://github.com/Gouryella/drip.git
synced 2026-02-23 21:00:44 +00:00
feat (client): Added system dependencies and optimized Windows process check logic
- Explicitly included golang.org/x/sys v0.38.0 in go.mod and removed indirect references - Optimized process liveness detection logic on Windows platforms using the golang.org/x/sys/windows package - Used OpenProcess and GetExitCodeProcess instead of Signal detection methods to improve accuracy - Updated command-line output and added an ASCII banner to improve user experience - Added blank lines to the github.com/spf13/cobra package to standardize import format
This commit is contained in:
2
go.mod
2
go.mod
@@ -10,6 +10,7 @@ require (
|
||||
github.com/vmihailenco/msgpack/v5 v5.4.1
|
||||
go.uber.org/zap v1.27.1
|
||||
golang.org/x/crypto v0.45.0
|
||||
golang.org/x/sys v0.38.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
@@ -31,6 +32,5 @@ require (
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/net v0.47.0 // indirect
|
||||
golang.org/x/sys v0.38.0 // indirect
|
||||
golang.org/x/text v0.31.0 // indirect
|
||||
)
|
||||
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
// getSysProcAttr returns platform-specific process attributes for daemonization
|
||||
@@ -17,11 +19,18 @@ func getSysProcAttr() *syscall.SysProcAttr {
|
||||
|
||||
// isProcessRunningOS checks if a process is running using OS-specific method
|
||||
func isProcessRunningOS(process *os.Process) bool {
|
||||
err := process.Signal(os.Signal(syscall.Signal(0)))
|
||||
handle, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(process.Pid))
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
defer windows.CloseHandle(handle)
|
||||
|
||||
var exitCode uint32
|
||||
if err := windows.GetExitCodeProcess(handle, &exitCode); err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return exitCode == 259
|
||||
}
|
||||
|
||||
// killProcessOS kills a process using OS-specific method
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"drip/internal/client/cli/ui"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -68,8 +69,17 @@ var versionCmd = &cobra.Command{
|
||||
return
|
||||
}
|
||||
|
||||
banner := `
|
||||
____ _
|
||||
| _ \ _ __(_)_ __
|
||||
| | | | '__| | '_ \
|
||||
| |_| | | | | |_) |
|
||||
|____/|_| |_| .__/
|
||||
|_|
|
||||
D R I P
|
||||
`
|
||||
fmt.Println(ui.Info(
|
||||
"Drip Client",
|
||||
banner,
|
||||
"",
|
||||
ui.KeyValue("Version", Version),
|
||||
ui.KeyValue("Git Commit", GitCommit),
|
||||
|
||||
Reference in New Issue
Block a user