mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 22:55:48 +01:00
parent
f4d1d02ded
commit
a52d68438b
1 changed files with 20 additions and 0 deletions
|
|
@ -379,6 +379,13 @@ func runFrontendDevWatcherCommand(cwd string, devCommand string, wg *sync.WaitGr
|
|||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Dir = dir
|
||||
|
||||
// not sure if this conditional is necessary, I mainly used it to prevent any issues with Windows
|
||||
// since I do not have a Windows dev environment at the moment
|
||||
// this conditional could be removed if found it causes no conflicts with Windows
|
||||
if runtime.GOOS != "windows" {
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
||||
}
|
||||
go func(ctx context.Context, devCommand string, cwd string, wg *sync.WaitGroup) {
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
|
|
@ -406,6 +413,19 @@ func runFrontendDevWatcherCommand(cwd string, devCommand string, wg *sync.WaitGr
|
|||
}
|
||||
}
|
||||
} else {
|
||||
// Experiencing the same issue on macOS BigSur
|
||||
// I'm using Vite, but I would imagine this could be an issue with Node (npm) in general
|
||||
// Also, after several edit/rebuild cycles any abnormal shutdown (crash or CTRL-C) may still leave Node running
|
||||
// Credit: https://stackoverflow.com/a/29552044/14764450 (same page as the Windows solution above)
|
||||
// Not tested on *nix
|
||||
pgid, err := syscall.Getpgid(cmd.Process.Pid)
|
||||
if err == nil {
|
||||
err := syscall.Kill(-pgid, 15) // note the minus sign
|
||||
if err != nil {
|
||||
LogRed("Error from '%s' when attempting to kill the process: %s", devCommand, err.Error())
|
||||
}
|
||||
}
|
||||
LogGreen("Dev command killed!")
|
||||
cancel()
|
||||
}
|
||||
wg.Wait()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue