#!Jinja2
[scheduler]
   [[events]]
       expected task failures = 1/t1, 1/t2, 1/t3, 1/t4, 1/stop2

[scheduling]
    [[graph]]
        R1 = """
            t1:start & t2:start => stop1 =>
            t3:start & t4:start => stop2?
            stop2:fail? => shutdown
        """

[runtime]
    [[T]]
        script = sleep 120 & echo $! >file; wait
    [[t1, t2, t3, t4]]
        inherit= T
    [[stop1]]
        script = """
            # Kill 1/t1 and 1/t2 explicitly.
            cylc kill $CYLC_WORKFLOW_ID// //1/t1 //1/t2 || true
        """
    [[stop2]]
        script = """
            # Kill 1/t3, 1/t4, and myself! implicitly (kill all active tasks).
            cylc kill "$CYLC_WORKFLOW_ID//*" || true
            sleep 30
        """
    [[shutdown]]
        script = "cylc stop $CYLC_WORKFLOW_ID"
