Skip to content

Commit

Permalink
fix(vite): close server and exit if stdin ends (#1857)
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpilot committed Feb 3, 2021
1 parent 000ee62 commit b065ede
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 @@ -337,13 +337,20 @@ export async function createServer(

server.transformIndexHtml = createDevHtmlTransformFn(server)

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

process.once('SIGTERM', exitProcess)

if (!process.stdin.isTTY) {
process.stdin.on('end', exitProcess)
process.stdin.resume()
}

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

0 comments on commit b065ede

Please sign in to comment.