0
0
Expressframework~5 mins

Graceful shutdown handling in Express - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Aapp.close()
Bserver.stop()
Cserver.close()
Dapp.shutdown()
What Node.js signal is typically used to initiate graceful shutdown?
ASIGINT
BSIGKILL
CSIGSTOP
DSIGCONT
Why is it important to wait for ongoing requests to finish during shutdown?
ATo block new users from connecting
BTo speed up server restart
CTo free memory immediately
DTo avoid losing data or causing errors for users
Where should you place code to close database connections during shutdown?
AInside the shutdown handler function
BIn the main app setup
CIn the request handler
DIn the server.listen callback
What happens if you call process.exit() immediately without cleanup?
AThe app waits for requests to finish
BThe app exits abruptly, possibly causing errors
CThe server restarts automatically
DThe app logs out users safely
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.