Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit90720e2

Browse files
fix: gracefully shutting down (#4145)
1 parent3818d7c commit90720e2

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

‎packages/webpack-cli/src/webpack-cli.ts‎

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ const WEBPACK_DEV_SERVER_PACKAGE = WEBPACK_DEV_SERVER_PACKAGE_IS_CUSTOM
7272
?(process.env.WEBPACK_DEV_SERVER_PACKAGEasstring)
7373
:"webpack-dev-server";
7474

75+
constEXIT_SIGNALS=["SIGINT","SIGTERM"];
76+
7577
interfaceInformation{
7678
Binaries?:string[];
7779
Browsers?:string[];
@@ -2532,11 +2534,35 @@ class WebpackCLI implements IWebpackCLI {
25322534
:compiler.options.watch,
25332535
);
25342536

2535-
if(isWatch(compiler)&&this.needWatchStdin(compiler)){
2536-
process.stdin.on("end",()=>{
2537-
process.exit(0);
2537+
if(isWatch(compiler)){
2538+
letneedForceShutdown=false;
2539+
2540+
EXIT_SIGNALS.forEach((signal)=>{
2541+
constlistener=()=>{
2542+
if(needForceShutdown){
2543+
process.exit(0);
2544+
}
2545+
2546+
this.logger.info(
2547+
"Gracefully shutting down. To force exit, press ^C again. Please wait...",
2548+
);
2549+
2550+
needForceShutdown=true;
2551+
2552+
compiler.close(()=>{
2553+
process.exit(0);
2554+
});
2555+
};
2556+
2557+
process.on(signal,listener);
25382558
});
2539-
process.stdin.resume();
2559+
2560+
if(this.needWatchStdin(compiler)){
2561+
process.stdin.on("end",()=>{
2562+
process.exit(0);
2563+
});
2564+
process.stdin.resume();
2565+
}
25402566
}
25412567
}
25422568
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp