Hopefully a fix for the 4001 bug we have been experiencing.
This commit is contained in:
parent
643cff06ea
commit
e80fb466e6
|
@ -1,4 +1,5 @@
|
||||||
const Koa = require("koa")
|
const Koa = require("koa")
|
||||||
|
const destroyable = require("server-destroy")
|
||||||
const electron = require("electron")
|
const electron = require("electron")
|
||||||
const koaBody = require("koa-body")
|
const koaBody = require("koa-body")
|
||||||
const logger = require("koa-pino-logger")
|
const logger = require("koa-pino-logger")
|
||||||
|
@ -44,6 +45,7 @@ if (electron.app && electron.app.isPackaged) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const server = http.createServer(app.callback())
|
const server = http.createServer(app.callback())
|
||||||
|
destroyable(server)
|
||||||
|
|
||||||
server.on("close", () => console.log("Server Closed"))
|
server.on("close", () => console.log("Server Closed"))
|
||||||
|
|
||||||
|
@ -51,3 +53,14 @@ module.exports = server.listen(env.PORT || 4001, () => {
|
||||||
console.log(`Budibase running on ${JSON.stringify(server.address())}`)
|
console.log(`Budibase running on ${JSON.stringify(server.address())}`)
|
||||||
automations.init()
|
automations.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
process.on("uncaughtException", err => {
|
||||||
|
console.error(err)
|
||||||
|
server.close()
|
||||||
|
server.destroy()
|
||||||
|
})
|
||||||
|
|
||||||
|
process.on("SIGTERM", () => {
|
||||||
|
server.close()
|
||||||
|
server.destroy()
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue