Skip to content

Commit b5ee78d

Browse files
feat: gracefully and force shutdown
1 parent f0dbea0 commit b5ee78d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lib/Server.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,11 +1114,26 @@ class Server {
11141114
if (this.options.setupExitSignals) {
11151115
const signals = ["SIGINT", "SIGTERM"];
11161116

1117+
let needForceShutdown = false;
1118+
11171119
signals.forEach((signal) => {
11181120
process.on(signal, () => {
1119-
this.stopCallback(() => {
1121+
if (needForceShutdown) {
11201122
// eslint-disable-next-line no-process-exit
11211123
process.exit();
1124+
}
1125+
1126+
this.logger.info(
1127+
"Gracefully shutting down. To force exit, press ^C again. Please wait..."
1128+
);
1129+
1130+
needForceShutdown = true;
1131+
1132+
this.stopCallback(() => {
1133+
this.compiler.close(() => {
1134+
// eslint-disable-next-line no-process-exit
1135+
process.exit();
1136+
});
11221137
});
11231138
});
11241139
});

0 commit comments

Comments
 (0)