Dont close server on tests

This commit is contained in:
Adria Navarro 2023-02-04 18:51:10 +00:00
parent 11a7742d90
commit c78038f059
2 changed files with 16 additions and 20 deletions

View File

@ -487,11 +487,6 @@
qs "^6.11.0" qs "^6.11.0"
tough-cookie "^4.1.2" tough-cookie "^4.1.2"
"@budibase/types@2.2.12-alpha.62":
version "2.2.12-alpha.62"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.2.12-alpha.62.tgz#385ef000610d5c00b83cb2eafda2bd63c86b7f3f"
integrity sha512-idlhB4fSyBCEDWsVvQvdmN9Dg9VAEwxZ8TLE9pGnXIRZPg48MKXPNn5AUT9zv6cDlbQdlU2tFFF8st9b6lyLuw==
"@cspotcode/source-map-support@^0.8.0": "@cspotcode/source-map-support@^0.8.0":
version "0.8.1" version "0.8.1"
resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1"

View File

@ -62,22 +62,23 @@ initialiseWebsockets(server)
let shuttingDown = false, let shuttingDown = false,
errCode = 0 errCode = 0
server.on("close", async () => {
// already in process if (!env.isTest()) {
if (shuttingDown) { server.on("close", async () => {
return // already in process
} if (shuttingDown) {
shuttingDown = true return
console.log("Server Closed") }
await automations.shutdown() shuttingDown = true
await redis.shutdown() console.log("Server Closed")
await events.shutdown() await automations.shutdown()
await Thread.shutdown() await redis.shutdown()
api.shutdown() await events.shutdown()
if (!env.isTest()) { await Thread.shutdown()
api.shutdown()
process.exit(errCode) process.exit(errCode)
} })
}) }
export default server.listen(env.PORT || 0, async () => { export default server.listen(env.PORT || 0, async () => {
await startup(app, server) await startup(app, server)