Change same-process-execution setting to make it future proof

This commit is contained in:
Jan Oberhauser 2020-01-17 19:49:31 -06:00
parent 95cb1b2788
commit e5ae4c77eb
4 changed files with 16 additions and 13 deletions

View file

@ -87,7 +87,7 @@ workflows are not CPU intensive and they have to start very fast it is possible
all directly in the main-process with this setting. all directly in the main-process with this setting.
```bash ```bash
export EXECUTIONS_SAME_PROCESS=true export EXECUTIONS_PROCESS=main
``` ```

View file

@ -55,6 +55,17 @@ const config = convict({
}, },
executions: { executions: {
// By default workflows get always executed in their own process.
// If this option gets set to "main" it will run them in the
// main-process instead.
process: {
doc: 'In what process workflows should be executed',
format: ['main', 'own'],
default: 'own',
env: 'EXECUTIONS_PROCESS'
},
// If a workflow executes all the data gets saved by default. This // If a workflow executes all the data gets saved by default. This
// could be a problem when a workflow gets executed a lot and processes // could be a problem when a workflow gets executed a lot and processes
// a lot of data. To not write the database full it is possible to // a lot of data. To not write the database full it is possible to
@ -84,12 +95,6 @@ const config = convict({
default: false, default: false,
env: 'EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS' env: 'EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS'
}, },
sameProcessExecution: {
doc: 'Executes the workflows in the same process instead of in a separate one',
default: false,
env: 'EXECUTIONS_SAME_PROCESS'
},
}, },
generic: { generic: {

View file

@ -94,9 +94,9 @@ export class WorkflowRunner {
* @memberof WorkflowRunner * @memberof WorkflowRunner
*/ */
async run(data: IWorkflowExecutionDataProcess, loadStaticData?: boolean): Promise<string> { async run(data: IWorkflowExecutionDataProcess, loadStaticData?: boolean): Promise<string> {
const sameProcessExecution = config.get('executions.sameProcessExecution') as boolean; const executionsProcess = config.get('executions.process') as string;
if (sameProcessExecution === true) { if (executionsProcess === 'main') {
return this.runSameProcess(data, loadStaticData); return this.runMainProcess(data, loadStaticData);
} }
return this.runSubprocess(data, loadStaticData); return this.runSubprocess(data, loadStaticData);
@ -112,7 +112,7 @@ export class WorkflowRunner {
* @returns {Promise<string>} * @returns {Promise<string>}
* @memberof WorkflowRunner * @memberof WorkflowRunner
*/ */
async runSameProcess(data: IWorkflowExecutionDataProcess, loadStaticData?: boolean): Promise<string> { async runMainProcess(data: IWorkflowExecutionDataProcess, loadStaticData?: boolean): Promise<string> {
if (loadStaticData === true && data.workflowData.id) { if (loadStaticData === true && data.workflowData.id) {
data.workflowData.staticData = await WorkflowHelpers.getStaticDataById(data.workflowData.id as string); data.workflowData.staticData = await WorkflowHelpers.getStaticDataById(data.workflowData.id as string);
} }

View file

@ -478,8 +478,6 @@ export class WorkflowExecute {
onCancel.shouldReject = false; onCancel.shouldReject = false;
onCancel(() => { onCancel(() => {
console.log('got cancellled');
gotCancel = true; gotCancel = true;
}); });