Skip to content

Commit

Permalink
Merge branch 'main' into forestgeo-app-acacia
Browse files Browse the repository at this point in the history
  • Loading branch information
siddheshraze authored Sep 16, 2024
2 parents 97e81c5 + 42ada06 commit a420d83
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
32 changes: 32 additions & 0 deletions frontend/components/processors/processormacros.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,35 @@ export function buildPaginatedQuery(config: QueryConfig): {

return { query, params: queryParams };
}

// Function to close all active connections
async function closeConnections() {
console.log('Closing all active connections...');
await poolMonitor.closeAllConnections();
console.log('All connections closed.');
}

// Function to handle graceful shutdown
async function gracefulShutdown() {
console.log('Initiating graceful shutdown...');
try {
await closeConnections();
console.log('Graceful shutdown complete.');
process.exit(0);
} catch (error) {
console.error('Error during graceful shutdown:', error);
process.exit(1);
}
}

// Capture SIGINT signal (triggered by ctrl+c)
process.on('SIGINT', async () => {
console.log('SIGINT signal received.');
await gracefulShutdown();
});

// Capture SIGTERM signal (triggered by process kill)
process.on('SIGTERM', async () => {
console.log('SIGTERM signal received.');
await gracefulShutdown();
});
3 changes: 1 addition & 2 deletions frontend/config/poolmonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ export class PoolMonitor {
this.logPoolStatus();
this.resetInactivityTimer();
});

// Initialize inactivity timer
this.resetInactivityTimer();
}

async getConnection(): Promise<PoolConnection> {
if (this.poolClosed) {
throw new Error('Connection pool is closed');
Expand Down

0 comments on commit a420d83

Please sign in to comment.