Skip to content
代码片段 群组 项目
提交 5ad0861b 编辑于 作者: Timotej Ecimovic's avatar Timotej Ecimovic
浏览文件

Further clean-up the shutdown sequence.

上级 d0e2d7ec
No related branches found
No related tags found
无相关合并请求
......@@ -35,7 +35,7 @@
"apidoc": "jsdoc2md src-shared/**/*.js src-electron/**/*.js > docs/api.md",
"format-code": "pretty-quick",
"pretty-quick": "pretty-quick",
"self-check": "node src-electron/main-process/electron-main.js selfCheck -g ./test/gen-template/zigbee/gen-templates.json",
"self-check": "node src-script/zap-start.js selfCheck -g ./test/gen-template/zigbee/gen-templates.json",
"version-stamp": "node src-script/zap-versionstamp.js",
"refresh-zap": "node src-script/zap-convert.js -z zcl-builtin/silabs/zcl.json test/resource/three-endpoint-device.zap -g test/gen-template/zigbee/gen-templates.json -o test/resource/three-endpoint-device.zap",
"gen": "node src-script/zap-generate.js --stateDirectory ~/.zap/gen -z ./zcl-builtin/silabs/zcl.json -g ./test/gen-template/zigbee/gen-templates.json -i ./test/resource/three-endpoint-device.zap -o ./tmp",
......
......@@ -55,8 +55,9 @@ function hookAppEvents() {
windowJs.windowCreateIfNotThere(args.httpPort)
})
app.on('quit', async () => {
await startup.shutdown()
app.on('will-quit', () => {
startup.shutdown()
if (env.mainDatabase() != null) {
// Use a sync call, because you can't have promises in the 'quit' event.
try {
......
......@@ -272,7 +272,9 @@ function startSelfCheck(options = { log: true, quit: true, cleanDb: true }) {
}
}
if (options.log) console.log('😎 Self-check done!')
if (options.quit && app != null) app.quit()
if (options.quit && app != null) {
app.quit()
}
})
.catch((err) => {
env.logError(err)
......@@ -398,7 +400,7 @@ function clearDatabaseFile(dbPath) {
function shutdown() {
env.logInfo('Shutting down HTTP server...')
return httpServer.shutdownHttpServer()
httpServer.shutdownHttpServerSync()
}
/**
......
......@@ -106,7 +106,7 @@ function windowCreate(port, args = {}) {
let api = await w.webContents.executeJavaScript(
'window.global_renderer_api'
)
console.log(api)
//console.log(api)
}
)
......
......@@ -188,6 +188,22 @@ function shutdownHttpServer() {
})
}
/**
* Promises to shut down the http server.
*
* @export
* @returns Promise that resolves when server is shut down.
*/
function shutdownHttpServerSync() {
if (httpServer != null) {
studio.clearReporting()
httpServer.close(() => {
env.logInfo('HTTP server shut down.')
httpServer = null
})
}
}
/**
* Port http server is listening on.
*
......@@ -204,4 +220,5 @@ function httpServerPort() {
// exports
exports.initHttpServer = initHttpServer
exports.shutdownHttpServer = shutdownHttpServer
exports.shutdownHttpServerSync = shutdownHttpServerSync
exports.httpServerPort = httpServerPort
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册