@budibase/worker 1.0.172 → 1.0.174

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/Dockerfile CHANGED
@@ -10,6 +10,7 @@ WORKDIR /app
10
10
  # copy files and install dependencies
11
11
  COPY . ./
12
12
  RUN yarn
13
+ RUN yarn global add pm2
13
14
 
14
15
  EXPOSE 4001
15
16
 
@@ -17,4 +18,5 @@ EXPOSE 4001
17
18
  # due to this causing yarn to stop installing dev dependencies
18
19
  # which are actually needed to get this environment up and running
19
20
  ENV NODE_ENV=production
20
- CMD ["yarn", "run:docker"]
21
+ ENV CLUSTER_MODE=${CLUSTER_MODE}
22
+ CMD ["./docker_run.sh"]
package/docker_run.sh ADDED
@@ -0,0 +1,5 @@
1
+ if [[ -z $CLUSTER_MODE ]]; then
2
+ yarn run:docker
3
+ else
4
+ yarn run:docker:cluster
5
+ fi
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/worker",
3
3
  "email": "hi@budibase.com",
4
- "version": "1.0.172",
4
+ "version": "1.0.174",
5
5
  "description": "Budibase background service",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -15,6 +15,7 @@
15
15
  "build": "rimraf dist/ && tsc",
16
16
  "postbuild": "copyfiles -u 1 src/**/*.hbs dist/",
17
17
  "run:docker": "node dist/index.js",
18
+ "run:docker:cluster": "pm2-runtime start pm2.config.js",
18
19
  "build:docker": "docker build . -t worker-service --label version=$BUDIBASE_RELEASE_VERSION",
19
20
  "dev:stack:init": "node ./scripts/dev/manage.js init",
20
21
  "dev:builder": "npm run dev:stack:init && nodemon",
@@ -31,9 +32,9 @@
31
32
  "author": "Budibase",
32
33
  "license": "GPL-3.0",
33
34
  "dependencies": {
34
- "@budibase/backend-core": "^1.0.172",
35
- "@budibase/pro": "1.0.171",
36
- "@budibase/string-templates": "^1.0.172",
35
+ "@budibase/backend-core": "^1.0.174",
36
+ "@budibase/pro": "1.0.173",
37
+ "@budibase/string-templates": "^1.0.174",
37
38
  "@koa/router": "^8.0.0",
38
39
  "@sentry/node": "6.17.7",
39
40
  "@techpass/passport-openidconnect": "^0.3.0",
@@ -89,5 +90,5 @@
89
90
  "./scripts/jestSetup.js"
90
91
  ]
91
92
  },
92
- "gitHead": "6af7e640852d273f757db5aee21e1794850bb612"
93
+ "gitHead": "7771898ed6c0d9b904eb5d754f07cab60f15c394"
93
94
  }
package/pm2.config.js ADDED
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ apps: [
3
+ {
4
+ script: "./dist/index.js",
5
+ instances: "max",
6
+ exec_mode: "cluster",
7
+ },
8
+ ],
9
+ }
@@ -17,7 +17,6 @@ const { googleCallbackUrl, oidcCallbackUrl } = require("./auth")
17
17
  const {
18
18
  withCache,
19
19
  CacheKeys,
20
- TTL,
21
20
  bustCache,
22
21
  } = require("@budibase/backend-core/cache")
23
22
 
@@ -256,58 +255,62 @@ exports.configChecklist = async function (ctx) {
256
255
  const tenantId = getTenantId()
257
256
 
258
257
  try {
259
- ctx.body = await withCache(CacheKeys.CHECKLIST, TTL.ONE_HOUR, async () => {
260
- let apps = []
261
- if (!env.MULTI_TENANCY || tenantId) {
262
- // Apps exist
263
- apps = await getAllApps({ idsOnly: true, efficient: true })
264
- }
258
+ ctx.body = await withCache(
259
+ CacheKeys.CHECKLIST,
260
+ env.CHECKLIST_CACHE_TTL,
261
+ async () => {
262
+ let apps = []
263
+ if (!env.MULTI_TENANCY || tenantId) {
264
+ // Apps exist
265
+ apps = await getAllApps({ idsOnly: true, efficient: true })
266
+ }
267
+
268
+ // They have set up SMTP
269
+ const smtpConfig = await getScopedFullConfig(db, {
270
+ type: Configs.SMTP,
271
+ })
272
+
273
+ // They have set up Google Auth
274
+ const googleConfig = await getScopedFullConfig(db, {
275
+ type: Configs.GOOGLE,
276
+ })
265
277
 
266
- // They have set up SMTP
267
- const smtpConfig = await getScopedFullConfig(db, {
268
- type: Configs.SMTP,
269
- })
270
-
271
- // They have set up Google Auth
272
- const googleConfig = await getScopedFullConfig(db, {
273
- type: Configs.GOOGLE,
274
- })
275
-
276
- // They have set up OIDC
277
- const oidcConfig = await getScopedFullConfig(db, {
278
- type: Configs.OIDC,
279
- })
280
-
281
- // They have set up an global user
282
- const users = await db.allDocs(
283
- getGlobalUserParams(null, {
284
- include_docs: true,
285
- limit: 1,
278
+ // They have set up OIDC
279
+ const oidcConfig = await getScopedFullConfig(db, {
280
+ type: Configs.OIDC,
286
281
  })
287
- )
288
- return {
289
- apps: {
290
- checked: apps.length > 0,
291
- label: "Create your first app",
292
- link: "/builder/portal/apps",
293
- },
294
- smtp: {
295
- checked: !!smtpConfig,
296
- label: "Set up email",
297
- link: "/builder/portal/manage/email",
298
- },
299
- adminUser: {
300
- checked: users && users.rows.length >= 1,
301
- label: "Create your first user",
302
- link: "/builder/portal/manage/users",
303
- },
304
- sso: {
305
- checked: !!googleConfig || !!oidcConfig,
306
- label: "Set up single sign-on",
307
- link: "/builder/portal/manage/auth",
308
- },
282
+
283
+ // They have set up an global user
284
+ const users = await db.allDocs(
285
+ getGlobalUserParams(null, {
286
+ include_docs: true,
287
+ limit: 1,
288
+ })
289
+ )
290
+ return {
291
+ apps: {
292
+ checked: apps.length > 0,
293
+ label: "Create your first app",
294
+ link: "/builder/portal/apps",
295
+ },
296
+ smtp: {
297
+ checked: !!smtpConfig,
298
+ label: "Set up email",
299
+ link: "/builder/portal/manage/email",
300
+ },
301
+ adminUser: {
302
+ checked: users && users.rows.length >= 1,
303
+ label: "Create your first user",
304
+ link: "/builder/portal/manage/users",
305
+ },
306
+ sso: {
307
+ checked: !!googleConfig || !!oidcConfig,
308
+ label: "Set up single sign-on",
309
+ link: "/builder/portal/manage/auth",
310
+ },
311
+ }
309
312
  }
310
- })
313
+ )
311
314
  } catch (err) {
312
315
  ctx.throw(err.status, err)
313
316
  }
@@ -20,6 +20,12 @@ if (!LOADED && isDev() && !isTest()) {
20
20
  LOADED = true
21
21
  }
22
22
 
23
+ function parseIntSafe(number) {
24
+ if (number) {
25
+ return parseInt(number)
26
+ }
27
+ }
28
+
23
29
  module.exports = {
24
30
  NODE_ENV: process.env.NODE_ENV,
25
31
  SELF_HOSTED: !!parseInt(process.env.SELF_HOSTED),
@@ -46,6 +52,7 @@ module.exports = {
46
52
  SMTP_FROM_ADDRESS: process.env.SMTP_FROM_ADDRESS,
47
53
  PLATFORM_URL: process.env.PLATFORM_URL,
48
54
  COOKIE_DOMAIN: process.env.COOKIE_DOMAIN,
55
+ CHECKLIST_CACHE_TTL: parseIntSafe(process.env.CHECKLIST_CACHE_TTL) || 3600,
49
56
  APPS_URL: process.env.APPS_URL,
50
57
  _set(key, value) {
51
58
  process.env[key] = value