chore: update .gitignore and improve cleanup handling in scripts

- Added .claude/hans/ to .gitignore to prevent tracking of specific directory.
- Updated cleanup calls in dev.mjs and start.mjs to use await for proper asynchronous handling.
- Enhanced error handling during cleanup in case of failures.
- Improved server failure handling in startServerAndWait function to ensure proper termination of failed processes.
This commit is contained in:
webdevcody
2026-01-03 23:36:22 -05:00
parent afb0937cb3
commit 586aabe11f
5 changed files with 36 additions and 8 deletions

1
.gitignore vendored
View File

@@ -81,6 +81,7 @@ blob-report/
docker-compose.override.yml
.claude/docker-compose.override.yml
.claude/hans/
pnpm-lock.yaml
yarn.lock

10
dev.mjs
View File

@@ -117,7 +117,7 @@ async function main() {
});
if (!processes.server) {
cleanup();
await cleanup();
process.exit(1);
}
@@ -175,9 +175,13 @@ async function main() {
}
// Run main function
main().catch((err) => {
main().catch(async (err) => {
console.error(err);
const cleanup = createCleanupHandler(processes);
cleanup();
try {
await cleanup();
} catch (cleanupErr) {
console.error('Cleanup error:', cleanupErr);
}
process.exit(1);
});

4
package-lock.json generated
View File

@@ -28,7 +28,7 @@
},
"apps/server": {
"name": "@automaker/server",
"version": "0.7.1",
"version": "0.7.3",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@anthropic-ai/claude-agent-sdk": "0.1.76",
@@ -78,7 +78,7 @@
},
"apps/ui": {
"name": "@automaker/ui",
"version": "0.7.1",
"version": "0.7.3",
"hasInstallScript": true,
"license": "SEE LICENSE IN LICENSE",
"dependencies": {

View File

@@ -610,6 +610,25 @@ export async function startServerAndWait({ serverPort, corsOriginEnv, npmArgs, c
if (!serverReady) {
log('Error: Server failed to start', 'red');
console.log('Check logs/server.log for details');
// Clean up the spawned server process that failed health check
if (serverProcess && !serverProcess.killed && serverProcess.pid) {
log('Terminating failed server process...', 'yellow');
try {
await killProcessTree(serverProcess.pid);
} catch (killErr) {
// Fallback: try direct kill if tree-kill fails
try {
serverProcess.kill('SIGKILL');
} catch {
// Process may have already exited
}
}
}
// Close the log stream
logStream.end();
return null;
}

View File

@@ -161,7 +161,7 @@ async function main() {
});
if (!processes.server) {
cleanup();
await cleanup();
process.exit(1);
}
@@ -256,9 +256,13 @@ async function main() {
}
// Run main function
main().catch((err) => {
main().catch(async (err) => {
console.error(err);
const cleanup = createCleanupHandler(processes);
cleanup();
try {
await cleanup();
} catch (cleanupErr) {
console.error('Cleanup error:', cleanupErr);
}
process.exit(1);
});