Skip to content

Commit

Permalink
trigger precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
0age committed Dec 5, 2024
1 parent aa39585 commit 8d17950
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions scripts/smoke-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,29 @@ async function killProcessOnPort(port) {
// Get port from environment variable or use default
const PORT = process.env.SMOKE_TEST_PORT || 3000;

// Helper to cleanup servers
async function cleanup(devServer, prodServer) {
log('\nStarting cleanup process...');
// Cleanup: ensure all servers are stopped gracefully
if (devServer) {
log('Stopping development server...');
devServer.kill('SIGTERM');
log('Waiting for development server cleanup...');
await new Promise(resolve => setTimeout(resolve, 1000)); // Wait for cleanup
log('Development server cleanup complete');
}
if (prodServer) {
log('Stopping production server...');
prodServer.kill('SIGTERM');
log('Waiting for production server cleanup...');
await new Promise(resolve => setTimeout(resolve, 1000)); // Wait for cleanup
log('Production server cleanup complete');
}
log('Running final port cleanup...');
await killProcessOnPort(PORT); // Final cleanup
log('Cleanup process complete');
}

async function main() {
let devServer = null;
let prodServer = null;
Expand Down Expand Up @@ -157,30 +180,12 @@ async function main() {
log('✓ Production server started successfully');

log('\n✅ All smoke tests passed!');
await cleanup(devServer, prodServer);
process.exit(0);
} catch (error) {
log('\n❌ Smoke tests failed:', error.message);
await cleanup(devServer, prodServer);
process.exit(1);
} finally {
log('\nStarting cleanup process...');
// Cleanup: ensure all servers are stopped gracefully
if (devServer) {
log('Stopping development server...');
devServer.kill('SIGTERM');
log('Waiting for development server cleanup...');
await new Promise(resolve => setTimeout(resolve, 1000)); // Wait for cleanup
log('Development server cleanup complete');
}
if (prodServer) {
log('Stopping production server...');
prodServer.kill('SIGTERM');
log('Waiting for production server cleanup...');
await new Promise(resolve => setTimeout(resolve, 1000)); // Wait for cleanup
log('Production server cleanup complete');
}
log('Running final port cleanup...');
await killProcessOnPort(PORT); // Final cleanup
log('Cleanup process complete');
}
}

Expand Down

0 comments on commit 8d17950

Please sign in to comment.