Skip to content

Commit

Permalink
Handle SIGINT gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddyGuthridge committed Mar 13, 2024
1 parent aab6533 commit e78c9b9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import server from './server';
import app from './server';

const port = parseInt(process.env.PORT as string);
const ip = process.env.IP as string;

server.listen(
const server = app.listen(
port,
ip,
() => console.log(`Waydriver backend running on http://${ip}:${port}/`)
);

// Handle Ctrl+C gracefully
process.on('SIGINT', () => {
server.close(() => console.log('Shutting down server gracefully.'));
});

0 comments on commit e78c9b9

Please sign in to comment.