Skip to content

Shutdown

Execute JavaScript when pipeline units shut down.

Unit close() methods are the shutdown counterpart to constructor() methods. They execute while the unit is still fully functional, before its internal shutdown sequence begins.

// @loader: tenx

import {TenXUnit, TenXEnv, TenXConsole} from '@tenx/tenx'

export class SymbolLoaderUnit extends TenXUnit {

    static shouldLoad(config) {
       return !TenXEnv.get("quiet") && (config.unitName == "symbolLoader");
    }

    constructor() {
        TenXConsole.log("Loading symbol libraries from: " + this.symbolPaths);
    }

    close() {
        TenXConsole.log("Shutting down symbol loader: " + this.unitName);
    }
}

Both constructor() and close() are defined in the same TenXUnit subclass. The shouldLoad(config) method applies to both — if a class is not loaded for a given unit, neither its constructor nor its close method will execute.

To load unit scripts see JavaScript configuration.

Options

Specify the options below to configure multiple Unit Shutdown JavaScript:

Name Description
unitShutdownActionsClassName JavaScript class name
unitShutdownActions 10x JavaScript shutdown statements to execute
unitShutdownActionsFile Declaring .js file

unitShutdownActionsClassName

JavaScript class name.

Type Required Names
String [unitShutdownActionsClassName, TenXUnitShutdownClassName]

Specifies the JavaScript class name in which unitShutdownActions are defined.

unitShutdownActions

10x JavaScript shutdown statements to execute.

Type Default Names
List [] [unitShutdownActions, TenXUnitShutdown]

JavaScript statements for shutting down target unit(s).

NOTE: This argument is not designed to be set directly, but instead by passing a .js launch file containing these statements nested within a TenXUnit sub-class close() method.

unitShutdownActionsFile

Declaring .js file.

Type Default Names
String "" [unitShutdownActionsFile, TenXUnitShutdownFile]

Specifies the .js file name declaring unitShutdownActions.


This unit is defined in unitShutdown/unit.yaml.