Fix Windows support: platform-abstract process lifecycle, binary update, and install script#41
Open
danbao wants to merge 2 commits intofastclaw-ai:mainfrom
Open
Fix Windows support: platform-abstract process lifecycle, binary update, and install script#41danbao wants to merge 2 commits intofastclaw-ai:mainfrom
danbao wants to merge 2 commits intofastclaw-ai:mainfrom
Conversation
…te, and install script Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
WeClaw builds for Windows (
windows/amd64,windows/arm64) in CI, but several core functions fail at runtime or compile-time on Windows:syscall.SIGINT, syscall.SIGTERMinsignal.NotifyContextstart.goSIGTERMdoes not exist on Windows — compilation fails or behavior is undefinedSignal(0)for process detectionstart.goprocessExists()Signal(0)always returnsnil— process detection never workssyscall.SIGTERMfor process terminationstart.gostopAllWeclaw(),restart.gopkill -ffor cleanupstart.gostopAllWeclaw()pkill— orphan cleanup never worksreplaceBinary()renameupdate.go.exeis file-locked on Windows —weclaw updatealways failsgetLatestVersion()uses GitHub APIupdate.goSolution
1. Platform abstraction via build tags (
proc_unix.go/proc_windows.go)Move all platform-specific logic into build-tagged files. The existing files only had
setSysProcAttr— now they also provide:notifyContext()SIGINT + SIGTERMos.InterruptprocessExists()Signal(0)tasklist /FI "PID eq X"signalTerminate()SIGTERMKill()(hard kill)killByName()pkill -ftaskkill /F /IM2. Remove
syscallfrom shared codestart.goandrestart.gono longer importsyscall. All platform calls go through the abstracted functions above.3.
replaceBinary()— Windows file-lock handlingOn Windows, a running
.execannot be overwritten. The new logic:.old.oldback4.
getLatestVersion()— avoid GitHub API rate limitsReplace
api.github.com/repos/.../releases/latest(JSON, 60 req/hr anonymous limit) with HTTP redirect fromgithub.com/.../releases/latest(no rate limit, no JSON parsing).5.
install.ps1— Windows installerNew PowerShell install script that:
$env:LOCALAPPDATA\weclawFiles Changed
cmd/proc_unix.go— AddednotifyContext,processExists,signalTerminate,killByNamecmd/proc_windows.go— Added Windows-specific implementations for all 5 platform functionscmd/start.go— Removedsyscallimport; usenotifyContext,signalTerminate,killByNamecmd/restart.go— Removedsyscallimport; usesignalTerminatecmd/update.go—getLatestVersionvia redirect;replaceBinarywith Windows file-lock handlinginstall.ps1— New Windows installer scriptTesting
go build ./...passes (darwin)GOOS=windows GOARCH=amd64 go build ./...passes (cross-compile)go test -race ./...all pass