Improving logging of publishing around CRON jobs, try to understand what is being disabled/created.
This commit is contained in:
parent
5669e82277
commit
9489e309b5
|
@ -77,18 +77,19 @@ async function initDeployedApp(prodAppId: any) {
|
|||
)
|
||||
).rows.map((row: any) => row.doc)
|
||||
await clearMetadata()
|
||||
console.log("You have " + automations.length + " automations")
|
||||
const { count } = await disableAllCrons(prodAppId)
|
||||
const promises = []
|
||||
console.log("Disabling prod crons..")
|
||||
await disableAllCrons(prodAppId)
|
||||
console.log("Prod Cron triggers disabled..")
|
||||
console.log("Enabling cron triggers for deployed app..")
|
||||
for (let automation of automations) {
|
||||
promises.push(enableCronTrigger(prodAppId, automation))
|
||||
}
|
||||
await Promise.all(promises)
|
||||
console.log("Enabled cron triggers for deployed app..")
|
||||
// sync the automations back to the dev DB - since there is now cron
|
||||
const results = await Promise.all(promises)
|
||||
const enabledCount = results
|
||||
.map(result => result.enabled)
|
||||
.filter(result => result).length
|
||||
console.log(
|
||||
`Cleared ${count} old CRON, enabled ${enabledCount} new CRON triggers for app deployment`
|
||||
)
|
||||
// sync the automations back to the dev DB - since there is now CRON
|
||||
// information attached
|
||||
await sdk.applications.syncApp(dbCore.getDevAppID(prodAppId), {
|
||||
automationOnly: true,
|
||||
|
|
|
@ -130,7 +130,8 @@ export async function disableAllCrons(appId: any) {
|
|||
}
|
||||
}
|
||||
}
|
||||
return Promise.all(promises)
|
||||
const results = await Promise.all(promises)
|
||||
return { count: results.length / 2 }
|
||||
}
|
||||
|
||||
export async function disableCronById(jobId: number | string) {
|
||||
|
@ -169,6 +170,7 @@ export async function enableCronTrigger(appId: any, automation: Automation) {
|
|||
const needsCreated =
|
||||
!sdk.automations.isReboot(automation) &&
|
||||
!sdk.automations.disabled(automation)
|
||||
let enabled = false
|
||||
|
||||
// need to create cron job
|
||||
if (validCron && needsCreated) {
|
||||
|
@ -191,8 +193,9 @@ export async function enableCronTrigger(appId: any, automation: Automation) {
|
|||
automation._id = response.id
|
||||
automation._rev = response.rev
|
||||
})
|
||||
enabled = true
|
||||
}
|
||||
return automation
|
||||
return { enabled, automation }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue