Add server-destroy

This commit is contained in:
Sebastien Chopin 2017-06-20 15:07:38 +02:00
parent 5ad640b294
commit ebc6da4c08
4 changed files with 15 additions and 1 deletions

View File

@ -54,6 +54,11 @@ const nuxtConfigFile = resolve(rootDir, argv['config-file'])
const nuxtConfig = loadNuxtConfig()
_.defaultsDeep(nuxtConfig, { watchers: { chokidar: { ignoreInitial: true } } })
// Fail if an error happened
process.on('unhandledRejection', function (err) {
throw err
})
// Start dev
let dev = startDev()

View File

@ -4,6 +4,7 @@ import ModuleContainer from './module'
import Renderer from './renderer'
import Options from './options'
import Debug from 'debug'
import enableDestroy from 'server-destroy'
const debug = Debug('nuxt:')
debug.color = 5
@ -57,7 +58,8 @@ export default class Nuxt extends Tapable {
// Close server on nuxt close
this.plugin('close', () => new Promise((resolve, reject) => {
server.close(err => {
// Destroy server by forcing every connection to be closed
server.destroy(err => {
debug('server closed')
if (err) {
return reject(err)
@ -68,6 +70,8 @@ export default class Nuxt extends Tapable {
resolve()
})
// Add server.destroy(cb) method
enableDestroy(server)
})
}

View File

@ -150,6 +150,7 @@
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-replace": "^1.1.1",
"rollup-watch": "^4.0.0",
"server-destroy": "^1.0.1",
"std-mocks": "^1.0.1",
"uglify-js": "^3.0.18"
},

View File

@ -5971,6 +5971,10 @@ serve-static@1.12.3, serve-static@^1.12.3:
parseurl "~1.3.1"
send "0.15.3"
server-destroy@^1.0.1:
version "1.0.1"
resolved "https://repository.neo9.pro/content/groups/global-npm/server-destroy/-/server-destroy-1.0.1.tgz#f13bf928e42b9c3e79383e61cc3998b5d14e6cdd"
set-blocking@^2.0.0, set-blocking@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"