Skip to content

Script Launcher Component

Using the Script Launcher component, it's possible to start a child script from your main script. Child scripts have their own script configuration and behave just like a regular script.

Usage

When implementing your script's onStart, execute, or onFinish methods, you can access the Script Launcher component through the provided ComponentProvider.

suspend fun execute(provider: ComponentProvider) {
    val scriptLauncher = provider.scriptLauncher()

    // Start a child script (pass the class, not a string ID)
    val handle = scriptLauncher.start(MyChildScript::class.java)

    // Optionally pass parameters to the child script
    val params = ScriptParameters()
    params.putString("productId", "12345")
    params.putInteger("quantity", 2)
    val handle = scriptLauncher.start(MyChildScript::class.java, params)

    // Check the execution status of running child scripts
    val status = handle.getStatus()
    provider.logger().info(
        "Tasks — total: ${status.totalTasks}, running: ${status.runningTasks}, " +
        "succeeded: ${status.succeededTasks}, errored: ${status.erroredTasks}"
    )
}

The start method throws StartScriptException if the child script cannot be started.

ScriptHandle

start returns a ScriptHandle that lets you poll the aggregated status of all tasks started for that child script:

Property Type Description
totalTasks Int Total unique tasks that have been executed.
runningTasks Int Tasks currently executing.
succeededTasks Int Tasks that finished with ExecutionResult.Success.
erroredTasks Int Tasks that finished with ExecutionResult.Error.

More Information

For more detailed information about creating child scripts, the @ChildScript annotation, passing data via ScriptParameters, and managing script lifecycles, refer to the child script documentation page.