packages/teraslice/lib/cluster/services/execution.js
function finishExecution(exId, err) {
        if (err) {
            const error = new TSError(err, {
                reason: `terminal error for execution: ${exId}, shutting down execution`,
                context: {
                    ex_id: exId,
                }
            });
            logger.error(error);
        }
        return getExecutionContext(exId)
            .then((execution) => {
                const status = execution._status;
                if (['stopping', 'stopped'].includes(status)) {
                    logger.debug(`execution ${exId} is already stopping which means there is no need to stop the execution`);
                    return true;
                }

                logger.debug(`execution ${exId} finished, shutting down execution`);
                return clusterService.stopExecution(exId).catch((stopErr) => {
                    const stopError = new TSError(stopErr, {
                        reason: 'error finishing the execution',
                        context: {
                            ex_id: exId,
                        }
                    });
                    logger.error(stopError);
                });
            });
    }
function finishExecution(exId, err) {
        if (err) {
            const error = new TSError(err, {
                reason: `terminal error for execution: ${exId}, shutting down execution`,
                context: {
                    ex_id: exId,
                }
            });
            logger.error(error);
        }
        return getExecutionContext(exId)
            .then((execution) => {
                const status = execution._status;
                if (['stopping', 'stopped'].includes(status)) {
                    logger.debug(`execution ${exId} is already stopping which means there is no need to stop the execution`);
                    return true;
                }

                logger.debug(`execution ${exId} finished, shutting down execution`);
                return clusterService.stopExecution(exId).catch((stopErr) => {
                    const stopError = new TSError(stopErr, {
                        reason: 'error finishing the execution',
                        context: {
                            ex_id: exId,
                        }
                    });
                    logger.error(stopError);
                });
            });
    }
function finishExecution ( exId , err ) { if ( err ) { const error = new TSError ( err , { reason : ` ${ exId } ` , context : { ex_id : exId , } } ) ; logger . error ( error ) ; } return getExecutionContext ( exId ) . then ( ( execution ) => { const status = execution . _status ; if ( [ 'stopping' , 'stopped' ] . includes ( status ) ) { logger . debug ( ` ${ exId } ` ) ; return true ; } logger . debug ( ` ${ exId } ` ) ; return clusterService . stopExecution ( exId ) . catch ( ( stopErr ) => { const stopError = new TSError ( stopErr , { reason : 'error finishing the execution' , context : { ex_id : exId , } } ) ; logger . error ( stopError ) ; } ) ; } ) ; }
safely stop the execution without setting the ex status to stopping or stopped
safely stop the execution without setting the ex status to stopping or stopped