@budibase/worker 3.10.2 → 3.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/worker",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "3.10.
|
|
4
|
+
"version": "3.10.3",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"dotenv": "8.6.0",
|
|
55
55
|
"email-validator": "^2.0.4",
|
|
56
56
|
"global-agent": "3.0.0",
|
|
57
|
+
"http-graceful-shutdown": "^3.1.12",
|
|
57
58
|
"ical-generator": "4.1.0",
|
|
58
59
|
"joi": "17.6.0",
|
|
59
60
|
"jsonwebtoken": "9.0.2",
|
|
@@ -120,5 +121,5 @@
|
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
},
|
|
123
|
-
"gitHead": "
|
|
124
|
+
"gitHead": "94264027da3376c3f544676c03c0241d88bd82b0"
|
|
124
125
|
}
|
|
@@ -47,13 +47,12 @@ describe("/api/global/self", () => {
|
|
|
47
47
|
})
|
|
48
48
|
})
|
|
49
49
|
|
|
50
|
-
it("should update
|
|
50
|
+
it("should update free trial confirmation date", async () => {
|
|
51
51
|
const user = await config.createUser()
|
|
52
52
|
await config.createSession(user)
|
|
53
53
|
|
|
54
54
|
const res = await config.api.self
|
|
55
55
|
.updateSelf(user, {
|
|
56
|
-
onboardedAt: "2023-03-07T14:10:54.869Z",
|
|
57
56
|
freeTrialConfirmedAt: "2024-03-17T14:10:54.869Z",
|
|
58
57
|
})
|
|
59
58
|
.expect(200)
|
|
@@ -61,7 +60,6 @@ describe("/api/global/self", () => {
|
|
|
61
60
|
const dbUser = (await config.getUser(user.email))!
|
|
62
61
|
|
|
63
62
|
user._rev = dbUser._rev
|
|
64
|
-
expect(dbUser.onboardedAt).toBe("2023-03-07T14:10:54.869Z")
|
|
65
63
|
expect(dbUser.freeTrialConfirmedAt).toBe("2024-03-17T14:10:54.869Z")
|
|
66
64
|
expect(res.body._id).toBe(user._id)
|
|
67
65
|
})
|
|
@@ -25,10 +25,8 @@ export const buildSelfSaveValidation = () => {
|
|
|
25
25
|
forceResetPassword: Joi.boolean().optional(),
|
|
26
26
|
firstName: OPTIONAL_STRING,
|
|
27
27
|
lastName: OPTIONAL_STRING,
|
|
28
|
-
onboardedAt: Joi.string().optional(),
|
|
29
28
|
freeTrialConfirmedAt: Joi.string().optional(),
|
|
30
29
|
appFavourites: Joi.array().optional(),
|
|
31
|
-
tours: Joi.object().optional(),
|
|
32
30
|
appSort: Joi.string().optional(),
|
|
33
31
|
}
|
|
34
32
|
return auth.joiValidator.body(Joi.object(schema).required().unknown(false))
|
package/src/index.ts
CHANGED
|
@@ -26,12 +26,12 @@ db.init()
|
|
|
26
26
|
import koaBody from "koa-body"
|
|
27
27
|
import http from "http"
|
|
28
28
|
import api from "./api"
|
|
29
|
+
import gracefulShutdown from "http-graceful-shutdown"
|
|
29
30
|
|
|
30
31
|
const koaSession = require("koa-session")
|
|
31
32
|
|
|
32
33
|
import { userAgent } from "koa-useragent"
|
|
33
34
|
|
|
34
|
-
import destroyable from "server-destroy"
|
|
35
35
|
import { initPro } from "./initPro"
|
|
36
36
|
import { handleScimBody } from "./middleware/handleScimBody"
|
|
37
37
|
|
|
@@ -86,29 +86,40 @@ app.use(auth.passport.session())
|
|
|
86
86
|
app.use(api.routes())
|
|
87
87
|
|
|
88
88
|
const server = http.createServer(app.callback())
|
|
89
|
-
destroyable(server)
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
server.on("close", async () => {
|
|
94
|
-
if (shuttingDown) {
|
|
95
|
-
return
|
|
96
|
-
}
|
|
97
|
-
shuttingDown = true
|
|
98
|
-
console.log("Server Closed")
|
|
90
|
+
const shutdown = async () => {
|
|
91
|
+
console.log("Worker service shutting down gracefully...")
|
|
99
92
|
timers.cleanup()
|
|
100
93
|
events.shutdown()
|
|
101
94
|
await redis.clients.shutdown()
|
|
102
95
|
await queue.shutdown()
|
|
103
|
-
|
|
104
|
-
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
gracefulShutdown(server, {
|
|
99
|
+
signals: "SIGINT SIGTERM",
|
|
100
|
+
timeout: 30000,
|
|
101
|
+
onShutdown: shutdown,
|
|
102
|
+
forceExit: !env.isTest,
|
|
103
|
+
finally: () => {
|
|
104
|
+
console.log("Worker service shutdown complete")
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
process.on("uncaughtException", async err => {
|
|
109
|
+
logging.logAlert("Uncaught exception.", err)
|
|
110
|
+
await shutdown()
|
|
111
|
+
if (!env.isTest) {
|
|
112
|
+
process.exit(1)
|
|
105
113
|
}
|
|
106
114
|
})
|
|
107
115
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
116
|
+
process.on("unhandledRejection", async reason => {
|
|
117
|
+
logging.logAlert("Unhandled Promise Rejection", reason as Error)
|
|
118
|
+
await shutdown()
|
|
119
|
+
if (!env.isTest) {
|
|
120
|
+
process.exit(1)
|
|
121
|
+
}
|
|
122
|
+
})
|
|
112
123
|
|
|
113
124
|
export default server.listen(parseInt(env.PORT || "4002"), async () => {
|
|
114
125
|
let startupLog = `Worker running on ${JSON.stringify(server.address())}`
|
|
@@ -125,17 +136,3 @@ export default server.listen(parseInt(env.PORT || "4002"), async () => {
|
|
|
125
136
|
// can't integrate directly into backend-core due to cyclic issues
|
|
126
137
|
await events.processors.init(proSdk.auditLogs.write)
|
|
127
138
|
})
|
|
128
|
-
|
|
129
|
-
process.on("uncaughtException", err => {
|
|
130
|
-
errCode = -1
|
|
131
|
-
logging.logAlert("Uncaught exception.", err)
|
|
132
|
-
shutdown()
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
process.on("SIGTERM", () => {
|
|
136
|
-
shutdown()
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
process.on("SIGINT", () => {
|
|
140
|
-
shutdown()
|
|
141
|
-
})
|