# A workflow that triggers a new flow in the graph and then shuts down
# so that we can restart with two active flows present.

[scheduler]
    [[events]]
        inactivity timeout = PT1M
        abort on inactivity timeout = True
[scheduling]
    [[graph]]
        R1 = "a => b => c => d"
[runtime]
    [[root]]
        pre-script = sleep 2
    [[a]]
       script = """
           if ((CYLC_TASK_FLOW_NUMBERS == 2)); then
               cylc__job__poll_grep_workflow_log -E "/c.* succeeded"
           fi
       """
    [[b, d]]
    [[c]]
       script = """
            if ((CYLC_TASK_FLOW_NUMBERS == 1)); then
                cylc trigger --flow=new --meta="cheese wizard" \
                    "$CYLC_WORKFLOW_ID//1/a"
                cylc__job__poll_grep_workflow_log -E "\[1/a/02\(flows=2\):submitted\] => running"
                cylc stop $CYLC_WORKFLOW_ID
            fi
       """
