mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
🎉 basic throtteling with cleaning logs
This commit is contained in:
parent
0b55fc2ed7
commit
05507fc19b
|
@ -41,6 +41,8 @@ import {
|
|||
|
||||
import * as config from '../config';
|
||||
|
||||
import { LessThanOrEqual } from "typeorm";
|
||||
|
||||
|
||||
/**
|
||||
* Checks if there was an error and if errorWorkflow is defined. If so it collects
|
||||
|
@ -79,6 +81,25 @@ function executeErrorWorkflow(workflowData: IWorkflowBase, fullRunData: IRun, mo
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prunes Saved Execution which are older than configured.
|
||||
* Throttled to be executed just once in configured timeframe.
|
||||
*
|
||||
*/
|
||||
let inThrottle: boolean;
|
||||
function pruneSavedExecutions(): void {
|
||||
console.log('THROTTLE:', inThrottle);
|
||||
if (!inThrottle) {
|
||||
inThrottle = true;
|
||||
Db.collections.Execution!.delete({ startedAt: LessThanOrEqual(new Date().toISOString()) });
|
||||
console.log('Deleting logs');
|
||||
setTimeout(() => {
|
||||
console.log('resetting throttle');
|
||||
inThrottle = false;
|
||||
}, 30000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pushes the execution out to all connected clients
|
||||
|
@ -251,6 +272,7 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {
|
|||
|
||||
// Save the Execution in DB
|
||||
const executionResult = await Db.collections.Execution!.save(executionData as IExecutionFlattedDb);
|
||||
pruneSavedExecutions()
|
||||
|
||||
if (fullRunData.finished === true && this.retryOf !== undefined) {
|
||||
// If the retry was successful save the reference it on the original execution
|
||||
|
|
Loading…
Reference in a new issue