Add max execution time for Workflows (#755)

* 🎉 basic setup and execution stopping

* 🚧 soft timeout for own process executions

* 🚧 add hard timeout for subprocesses

* 🚧 add soft timeout to main thread

* 🔧 set default timeout to 5 mins --> 500s

* 💡 adding documentation to configs

* 🚧 deactivate timeout by default

* 🚧 add logic of max execution timeout

*  adding timeout to settings in frontend and server

* 🎨 improve naming

* 💡 fix change in config docs

* ✔️ fixing compilation issue

* 🎨 add format for new config variables

* 👌 type cast before checking equality

*  Improve error message if NodeType is not known

* 🐳 Tag also rpi latest image

* 🐛 Fix Postgres issue with Node.js 14 #776

* 🚧 add toggle to activate workflow timeout

* 💄 improving UX of setting a timeout and its duration

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Ben Hesseldieck
2020-07-29 14:12:54 +02:00
committed by GitHub
parent 6e06da99fb
commit 051598d30e
13 changed files with 232 additions and 25 deletions

View File

@@ -190,17 +190,18 @@ process.on('message', async (message: IProcessMessage) => {
// Once the workflow got executed make sure the process gets killed again
process.exit();
} else if (message.type === 'stopExecution') {
} else if (message.type === 'stopExecution' || message.type === 'timeout') {
// The workflow execution should be stopped
let runData: IRun;
if (workflowRunner.workflowExecute !== undefined) {
// Workflow started already executing
runData = workflowRunner.workflowExecute.getFullRunData(workflowRunner.startedAt);
// If there is any data send it to parent process
await workflowRunner.workflowExecute.processSuccessExecution(workflowRunner.startedAt, workflowRunner.workflow!);
const timeOutError = message.type === 'timeout' ? { message: 'Workflow execution timed out!' } as IExecutionError : undefined
// If there is any data send it to parent process, if execution timedout add the error
await workflowRunner.workflowExecute.processSuccessExecution(workflowRunner.startedAt, workflowRunner.workflow!, timeOutError);
} else {
// Workflow did not get started yet
runData = {
@@ -209,7 +210,7 @@ process.on('message', async (message: IProcessMessage) => {
runData: {},
},
},
finished: true,
finished: message.type !== 'timeout',
mode: workflowRunner.data!.executionMode,
startedAt: workflowRunner.startedAt,
stoppedAt: new Date(),
@@ -218,7 +219,7 @@ process.on('message', async (message: IProcessMessage) => {
workflowRunner.sendHookToParentProcess('workflowExecuteAfter', [runData]);
}
await sendToParentProcess('end', {
await sendToParentProcess(message.type === 'timeout' ? message.type : 'end', {
runData,
});