#!Jinja2

[scheduler]
    UTC mode = True
    [[events]]
        expected task failures = 1/killable-1, 1/killable-2, 1/killable-3

[scheduling]
    [[graph]]
        R1 = """
            KILLABLE:submit-all? => killer
            KILLABLE:submit-fail-all? => stopper
        """

[runtime]
    [[KILLABLE]]
        init-script="""
            echo "CYLC_JOB_PID=$$" >>"$0.status"
            sleep 60
        """
        script=true
    [[killable-1, killable-2, killable-3]]
        inherit=KILLABLE
    [[killer]]
        script="""
            cylc__job__wait_cylc_message_started
            cylc__job__poll_grep_workflow_log -F '1/killable-1 -triggered'
            cylc__job__poll_grep_workflow_log -F '1/killable-2 -triggered'
            cylc__job__poll_grep_workflow_log -F '1/killable-3 -triggered'
            # (Avoid killing myself if my started message hasn't arrived yet:)
            cylc kill "${CYLC_WORKFLOW_ID}//*/killable*:submitted"
        """
    [[stopper]]
        script=cylc stop "${CYLC_WORKFLOW_ID}"
