Minor fix for automations, the wrong function had the environment variables being added to environment, this is very minor, it simply makes sure that environment variables are in context for the whole of the automation runner - e.g. if utilising many datasources each of them doesn't need to re-retrieve the environment variables, instead they will be available based on the env vars retrieved at the start of the execution.
This commit is contained in:
parent
1334481da5
commit
0734e5d0d5
|
@ -464,13 +464,17 @@ 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 automationOrchestrator = new Orchestrator(job)
|
const envVars = await sdkUtils.getEnvironmentVariables()
|
||||||
try {
|
// put into automation thread for whole context
|
||||||
const response = await automationOrchestrator.execute()
|
await context.doInEnvironmentContext(envVars, async () => {
|
||||||
callback(null, response)
|
const automationOrchestrator = new Orchestrator(job)
|
||||||
} catch (err) {
|
try {
|
||||||
callback(err)
|
const response = await automationOrchestrator.execute()
|
||||||
}
|
callback(null, response)
|
||||||
|
} catch (err) {
|
||||||
|
callback(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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()
|
const automationOrchestrator = new Orchestrator(job)
|
||||||
// put into automation thread for whole context
|
await automationOrchestrator.stopCron("stalled")
|
||||||
await context.doInEnvironmentContext(envVars, async () => {
|
|
||||||
const automationOrchestrator = new Orchestrator(job)
|
|
||||||
await automationOrchestrator.stopCron("stalled")
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue