chore: commit pending gateway changes

This commit is contained in:
2026-05-10 22:34:15 +08:00
parent 53f8edfb67
commit d59756a27c
71 changed files with 15106 additions and 656 deletions
+16 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env node
import { spawn } from 'node:child_process';
import { spawn, spawnSync } from 'node:child_process';
import { readdir, stat } from 'node:fs/promises';
import path from 'node:path';
import process from 'node:process';
@@ -12,6 +12,7 @@ const shutdownGraceMs = Number(process.env.GO_WATCH_SHUTDOWN_GRACE_MS || 2500);
const restartDelayMs = Number(process.env.GO_WATCH_RESTART_DELAY_MS || 200);
const commandIndex = process.argv.indexOf('--');
const command = commandIndex >= 0 ? process.argv.slice(commandIndex + 1) : ['go', 'run', './cmd/gateway'];
const prestartCommand = process.env.GO_WATCH_PRESTART || '';
const ignoredDirs = new Set([
'.git',
'.nx',
@@ -21,7 +22,7 @@ const ignoredDirs = new Set([
'tmp',
'vendor',
]);
const watchedExtensions = new Set(['.go', '.mod', '.sum']);
const watchedExtensions = new Set(['.go', '.mod', '.sum', '.sql']);
if (!command.length) {
console.error('[go-watch] missing command after --');
@@ -89,6 +90,19 @@ function start() {
if (stopped) {
return;
}
if (prestartCommand) {
log(`prestart: ${prestartCommand}`);
const result = spawnSync(prestartCommand, {
cwd: watchRoot,
env: process.env,
shell: true,
stdio: 'inherit',
});
if (result.status !== 0) {
log(`prestart failed code=${result.status ?? 'null'} signal=${result.signal ?? 'null'}`);
return;
}
}
log(`starting: ${command.join(' ')}`);
child = spawn(command[0], command.slice(1), {
cwd: watchRoot,