Hopefully a fix for the 4001 bug we have been experiencing.

This commit is contained in:
mike12345567 2020-12-04 12:09:02 +00:00
parent 277524b86e
commit 6f3c4ba0ea
1 changed files with 13 additions and 0 deletions

View File

@ -1,4 +1,5 @@
const Koa = require("koa")
const destroyable = require("server-destroy")
const electron = require("electron")
const koaBody = require("koa-body")
const logger = require("koa-pino-logger")
@ -44,6 +45,7 @@ if (electron.app && electron.app.isPackaged) {
}
const server = http.createServer(app.callback())
destroyable(server)
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())}`)
automations.init()
})
process.on("uncaughtException", err => {
console.error(err)
server.close()
server.destroy()
})
process.on("SIGTERM", () => {
server.close()
server.destroy()
})