Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions workers/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"runtime"
"strconv"
"strings"
"syscall"
"time"

"github.com/spf13/pflag"
Expand Down Expand Up @@ -137,7 +136,7 @@ func (r *Runner) Run(ctx context.Context, baseDir string) error {
if err != nil {
return fmt.Errorf("failed creating command: %w", err)
}
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} // set process group ID for shutdown
setSysProcAttr(cmd) // set process group ID for shutdown

// Direct logging output to provided logger, if available.
if r.LoggingOptions.PreparedLogger != nil {
Expand Down Expand Up @@ -243,10 +242,12 @@ func sendInterrupt(process *os.Process) error {
if runtime.GOOS == "windows" {
return process.Kill()
}
return process.Signal(syscall.SIGINT)
return osSendInterrupt(process)
}

func sendKill(process *os.Process) error {
// shutting down the process group (ie including all child processes)
return syscall.Kill(-process.Pid, syscall.SIGKILL)
if runtime.GOOS == "windows" {
return process.Kill()
}
return osSendKill(process)
}
22 changes: 22 additions & 0 deletions workers/run_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//go:build !windows

package workers

import (
"os"
"os/exec"
"syscall"
)

func setSysProcAttr(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
}

func osSendInterrupt(process *os.Process) error {
return process.Signal(syscall.SIGINT)
}

func osSendKill(process *os.Process) error {
// Shut down the process group (including all child processes)
return syscall.Kill(-process.Pid, syscall.SIGKILL)
}
20 changes: 20 additions & 0 deletions workers/run_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//go:build windows

package workers

import (
"os"
"os/exec"
)

func setSysProcAttr(cmd *exec.Cmd) {
// Setpgid is not supported on Windows; no-op
}

func osSendInterrupt(process *os.Process) error {
return process.Kill()
}

func osSendKill(process *os.Process) error {
return process.Kill()
}
7 changes: 6 additions & 1 deletion workers/typescript/protogen.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ const { resolve } = require('path');
const { promisify } = require('util');
const glob = require('glob');
const { statSync, mkdirSync } = require('fs');

// Normalize path separators for glob (Windows uses backslashes, glob requires forward slashes)
function toGlobPath(p) {
return p.replace(/\\/g, '/');
}
const pbjs = require('protobufjs-cli/pbjs');
const pbts = require('protobufjs-cli/pbts');

Expand Down Expand Up @@ -73,7 +78,7 @@ async function compileProtos(dtsOutputFile, ...args) {
async function main() {
mkdirSync(outputDir, { recursive: true });

const protoFiles = glob.sync(resolve(protoBaseDir, '**/*.proto'));
const protoFiles = glob.sync(toGlobPath(resolve(protoBaseDir, '**/*.proto')));
const protosMTime = Math.max(...protoFiles.map(mtime));
const genMTime = mtime(jsOutputFile);

Expand Down
Loading