Recall & Review
beginner
What is graceful shutdown in an Express server?
Graceful shutdown means stopping the server without abruptly cutting off active connections. It waits for ongoing requests to finish before closing.
Click to reveal answer
beginner
Which Node.js event is commonly used to trigger graceful shutdown?
The 'SIGINT' signal is often used. It signals the app to start cleanup before exiting, like when you press Ctrl+C in the terminal.
Click to reveal answer
intermediate
Why should you close the HTTP server during graceful shutdown?
Closing the HTTP server stops it from accepting new requests but lets existing requests finish, preventing sudden disconnections.
Click to reveal answer
intermediate
How can you handle cleanup tasks like closing database connections during shutdown?
You add cleanup code inside the shutdown handler to close resources like database connections or file streams before exiting.
Click to reveal answer
beginner
What happens if you don't implement graceful shutdown in an Express app?
The server may drop active requests abruptly, causing errors for users and possible data loss or corruption.
Click to reveal answer
Which method stops an Express server from accepting new requests during shutdown?
✗ Incorrect
The server.close() method stops the server from accepting new connections but allows existing ones to finish.
What Node.js signal is typically used to initiate graceful shutdown?
✗ Incorrect
SIGINT is sent when you press Ctrl+C and is commonly used to start graceful shutdown.
Why is it important to wait for ongoing requests to finish during shutdown?
✗ Incorrect
Waiting ensures users' requests complete successfully without abrupt errors.
Where should you place code to close database connections during shutdown?
✗ Incorrect
Cleanup code belongs in the shutdown handler to run before the app exits.
What happens if you call process.exit() immediately without cleanup?
✗ Incorrect
Immediate exit stops everything without cleanup, risking errors and data loss.
Explain how to implement graceful shutdown in an Express server.
Think about stopping new requests, finishing current ones, and cleaning resources.
You got /5 concepts.
Why is graceful shutdown important in web servers like Express?
Consider what happens if the server stops suddenly.
You got /4 concepts.