Skip to content

Commit

Permalink
fix: fix graceful shutdown on sigint
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 14, 2021
1 parent 8401c89 commit fe7238c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/vite/src/node/server/index.ts
Expand Up @@ -248,8 +248,15 @@ export async function createServer(
}
}

process.once('SIGINT', server.close)
process.once('SIGTERM', server.close)
const onExit = async () => {
try {
await server.close()
} finally {
process.exit(0)
}
}
process.once('SIGINT', onExit)
process.once('SIGTERM', onExit)

watcher.on('change', async (file) => {
file = normalizePath(file)
Expand Down

0 comments on commit fe7238c

Please sign in to comment.