Skip to content

Commit

Permalink
fix: close sockets opened by PouchDB on server stop
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Dec 4, 2016
1 parent 6d2de98 commit 9a2bcef
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ var getDefaults = require('./defaults')
var pouchDbConfig = require('./db/pouchdb')
var storeConfig = require('./store')

var watchPouchDbSockets = require('../utils/watch-pouchdb-sockets')

function getConfig (server, config, callback) {
defaultsDeep(config, getDefaults())

Expand All @@ -32,6 +34,14 @@ function getConfig (server, config, callback) {
}
}

// see https://github.com/hoodiehq/hoodie-server/issues/521
var sockets = watchPouchDbSockets(state.PouchDB)
server.on('stop', function () {
sockets.forEach(function (socket) {
socket.cancel()
})
})

// check if app has public folder. Fallback to Hoodie’s public folder if not
try {
statSync(config.paths.public).isDirectory()
Expand Down

0 comments on commit 9a2bcef

Please sign in to comment.