Merge pull request #9650 from Budibase/fix/automation-perf-improvement

Automation environment variable fix
This commit is contained in:
Michael Drury 2023-02-10 15:39:33 +00:00 committed by GitHub
commit 860939fc88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 13 deletions

View File

@ -464,6 +464,9 @@ export function execute(job: Job, callback: WorkerCallback) {
throw new Error("Unable to execute, event doesn't contain app ID.") throw new Error("Unable to execute, event doesn't contain app ID.")
} }
return context.doInAppContext(appId, async () => { return context.doInAppContext(appId, async () => {
const envVars = await sdkUtils.getEnvironmentVariables()
// put into automation thread for whole context
await context.doInEnvironmentContext(envVars, async () => {
const automationOrchestrator = new Orchestrator(job) const automationOrchestrator = new Orchestrator(job)
try { try {
const response = await automationOrchestrator.execute() const response = await automationOrchestrator.execute()
@ -472,6 +475,7 @@ export function execute(job: Job, callback: WorkerCallback) {
callback(err) callback(err)
} }
}) })
})
} }
export const removeStalled = async (job: Job) => { export const removeStalled = async (job: Job) => {
@ -480,11 +484,7 @@ export const removeStalled = async (job: Job) => {
throw new Error("Unable to execute, event doesn't contain app ID.") throw new Error("Unable to execute, event doesn't contain app ID.")
} }
await context.doInAppContext(appId, async () => { await context.doInAppContext(appId, async () => {
const envVars = await sdkUtils.getEnvironmentVariables()
// put into automation thread for whole context
await context.doInEnvironmentContext(envVars, async () => {
const automationOrchestrator = new Orchestrator(job) const automationOrchestrator = new Orchestrator(job)
await automationOrchestrator.stopCron("stalled") await automationOrchestrator.stopCron("stalled")
}) })
})
} }