graceful shutdown은 종료 시그널을 받았을 때 서버를 깔끔하게 멈추는 것을 의미합니다. 진행 중인 요청을 끝내고, 연결(DB 등)을 닫고, 리소스를 해제하는 것이지, 갑자기 죽여 진행 중인 작업을 버리는 것이 아닙니다. 무중단 배포와 신뢰성에 필수적입니다.
갑작스러운 종료가 문제인 이유
text
Without graceful shutdown, when the process is killed (deploy, scale-down, crash):
✗ In-flight requests are dropped → users get errors
✗ DB transactions left incomplete
✗ Connections not closed cleanly → leaks/locks
배포와 오토스케일링 중에 프로세스는 끊임없이 멈춥니다. 이를 깔끔하게 하는 것이 배포를 매끄럽게 만듭니다.
구현하기
js
http ;
server = http.(app);
server.();
() {
.();
server.( () => {
db.();
redis.();
.();
process.();
});
( {
.();
process.();
}, ).();
}
process.(, ());
process.(, ());
