0
0
Node.jsframework~5 mins

Graceful shutdown handling in Node.js - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is graceful shutdown in Node.js?
Graceful shutdown means closing the server and cleaning up resources properly before the app stops, so no requests are lost or data corrupted.
Click to reveal answer
beginner
Which Node.js event is commonly used to detect when the process should shut down?
The 'SIGINT' signal is often used to detect when the user presses Ctrl+C to stop the process.
Click to reveal answer
intermediate
Why should you stop accepting new requests during graceful shutdown?
Stopping new requests prevents the server from starting work it can't finish before shutting down, avoiding errors or lost data.
Click to reveal answer
intermediate
How can you ensure all ongoing requests finish before the server closes?
You wait for all current requests to complete, often by tracking active connections and closing the server only after they finish.
Click to reveal answer
intermediate
What is a common method to clean up resources during shutdown in Node.js?
Closing database connections, clearing timers, and releasing file handles are common cleanup steps during shutdown.
Click to reveal answer
Which signal is typically used to trigger graceful shutdown in a Node.js app?
ASIGCONT
BSIGKILL
CSIGSTOP
DSIGINT
What should a server do first when starting graceful shutdown?
AStop accepting new requests
BRestart the server
CExit the process
DClose database connections immediately
Why is it important to wait for ongoing requests to finish before shutdown?
ATo restart the server faster
BTo avoid losing data or breaking client connections
CTo speed up shutdown
DTo free memory immediately
Which Node.js method helps to stop the server from accepting new connections?
Aserver.close()
Bserver.listen()
Cprocess.exit()
Dserver.open()
What is NOT a typical cleanup task during graceful shutdown?
AClosing database connections
BClearing timers
COpening new network sockets
DReleasing file handles
Explain the steps to implement graceful shutdown in a Node.js server.
Think about what happens from signal to process exit.
You got /5 concepts.
    Why is graceful shutdown important for a Node.js application?
    Consider what happens if the app stops suddenly.
    You got /4 concepts.