fix: graceful shutdown (#3821)

* fix: missing graceful shutdown handler

* fix: asar - use async fs operation

* fix: scheduler - graceful shutdown and wait for running jobs to complete
This commit is contained in:
LK HO
2021-04-12 23:45:33 +08:00
committed by GitHub
parent 71aa0c9346
commit a103127545
4 changed files with 39 additions and 23 deletions

View File

@@ -40,11 +40,11 @@ module.exports = {
}
},
async unload () {
if (this.fdCache) {
const fds = Object.values(this.fdCache)
if (fds.length > 0) {
WIKI.logger.info('Closing ASAR file descriptors...')
for (const fdItem in this.fdCache) {
fs.closeSync(this.fdCache[fdItem].fd)
}
const closeAsync = require('util').promisify(fs.close)
await Promise.all(fds.map(x => closeAsync(x.fd)))
this.fdCache = {}
}
},