Browse Source

Adding a mechanism for disabling cron jobs when an app is unpublished.

pull/3418/head
mike12345567 5 years ago
parent
commit
494e042dd8
  1. 4
      packages/server/src/api/controllers/application.js
  2. 9
      packages/server/src/automations/utils.js

4
packages/server/src/api/controllers/application.js

@ -46,6 +46,7 @@ const {
const { getTenantId, isMultiTenant } = require("@budibase/auth/tenancy")
const { syncGlobalUsers } = require("./user")
const { app: appCache } = require("@budibase/auth/cache")
const { cleanupAutomations } = require("../../automations/utils")
const URL_REGEX_SLASH = /\/|\\/g
@ -319,6 +320,9 @@ exports.delete = async ctx => {
if (!env.isTest() && !ctx.query.unpublish) {
await deleteApp(ctx.params.appId)
}
if (ctx.query.unpublish) {
await cleanupAutomations(ctx.params.appId)
}
// make sure the app/role doesn't stick around after the app has been deleted
await removeAppFromUserRoles(ctx, ctx.params.appId)
await appCache.invalidateAppMetadata(ctx.params.appId)

9
packages/server/src/automations/utils.js

@ -163,3 +163,12 @@ exports.checkForWebhooks = async ({ appId, oldAuto, newAuto }) => {
}
return newAuto
}
/**
* When removing an app/unpublishing it need to make sure automations are cleaned up (cron).
* @param appId {string} the app that is being removed.
* @return {Promise<void>} clean is complete if this succeeds.
*/
exports.cleanupAutomations = async appId => {
await exports.disableAllCrons(appId)
}

Loading…
Cancel
Save