Skip to content

Commit

Permalink
fix: dont handle sigterm in middleware mode (#8550)
Browse files Browse the repository at this point in the history
Co-authored-by: patak <matias.capeletto@gmail.com>
  • Loading branch information
bluwy and patak-dev committed Jun 12, 2022
1 parent 18d74aa commit c6f43dd
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions packages/vite/src/node/server/index.ts
Expand Up @@ -299,7 +299,6 @@ export async function createServer(
const container = await createPluginContainer(config, moduleGraph, watcher)
const closeHttpServer = createServerCloseFn(httpServer)

// eslint-disable-next-line prefer-const
let exitProcess: () => void

const server: ViteDevServer = {
Expand Down Expand Up @@ -342,10 +341,11 @@ export async function createServer(
return startServer(server, port, isRestart)
},
async close() {
process.off('SIGTERM', exitProcess)

if (!middlewareMode && process.env.CI !== 'true') {
process.stdin.off('end', exitProcess)
if (!middlewareMode) {
process.off('SIGTERM', exitProcess)
if (process.env.CI !== 'true') {
process.stdin.off('end', exitProcess)
}
}

await Promise.all([
Expand Down Expand Up @@ -382,18 +382,18 @@ export async function createServer(

server.transformIndexHtml = createDevHtmlTransformFn(server)

exitProcess = async () => {
try {
await server.close()
} finally {
process.exit()
if (!middlewareMode) {
exitProcess = async () => {
try {
await server.close()
} finally {
process.exit()
}
}
process.once('SIGTERM', exitProcess)
if (process.env.CI !== 'true') {
process.stdin.on('end', exitProcess)
}
}

process.once('SIGTERM', exitProcess)

if (!middlewareMode && process.env.CI !== 'true') {
process.stdin.on('end', exitProcess)
}

const { packageCache } = config
Expand Down

0 comments on commit c6f43dd

Please sign in to comment.