github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/user-guide/schedulers.md (about)

     1  # Schedulers
     2  
     3  > Overview of the different schedulers (or 'run modes') in Murex
     4  
     5  There are a few distinct schedulers (or run modes) in Murex which are invoked
     6  by builtin commands. This means you can alter the way commands are executed
     7  dynamically within Murex shell scripts.
     8  
     9  ## Normal
    10  
    11  This is a traditional shell where anything in a pipeline (eg `cmd1 -> cmd2 -> cmd3`)
    12  is executed in parallel. The scheduler only pauses launching new commands when
    13  the last command in any pipeline is still executing. A pipeline could be multiple
    14  commands (like above) or a single command (eg `top`).
    15  
    16  **Normal** is the default run mode. When running in a stricter mode, you can not
    17  reset the run mode back to **normal**. You can, however, switch to `unsafe`.
    18  
    19  ## Unsafe
    20  
    21  This is the same as **normal** except that `unsafe` blocks always return zero
    22  exit numbers. The purpose for this is to enable "normal" like scheduling inside
    23  stricter code blocks that might exit if the last function was a non-zero exit
    24  number.
    25  
    26  ## Try
    27  
    28  This is the weakest of all the stricter run modes. It does check the exit number
    29  to confirm if the last function was successful, but only the last function in
    30  any given pipeline. So in `cmd1 -> cmd2 -> cmd3`, if `cmd1` or `cmd2` fail, the
    31  `try` block doesn't exit.
    32  
    33  The benefit of run mode is that it still supports commands running in parallel.
    34  
    35  ## Try Pipe
    36  
    37  This runs the commands sequentially because the stderr and the exit number of
    38  each command is checked irrespective of whether that command is at the start of
    39  the pipeline (eg `start -> middle -> end`), or anywhere else.
    40  
    41  This offers better coverage of exit numbers but at the cost of parallelisation.
    42  
    43  ## Try Err
    44  
    45  This is similar to `try` and **normal** where commands in a pipeline are run in
    46  parallel. The key difference with `tryerr` is that  Murex validates the stderr
    47  as well as the exit number of the last command in any pipeline.
    48  
    49  If stderr is greater than stdout (per bytes written) **OR** the exit number is
    50  non-zero then the scheduler exits that entire block.
    51  
    52  ## Try Pipe Err
    53  
    54  This runs the commands sequentially because the stderr and the exit number of
    55  each command is checked irrespective of whether that command is at the start of
    56  the pipeline (eg `start -> middle -> end`), or anywhere else.
    57  
    58  Like with `tryerr`, if stderr is greater than stdout (per bytes written) **OR**
    59  the exit number is non-zero then the scheduler exits that entire block. Unlike
    60  with `tryerr`, this check happens on every command rather than the last command
    61  in the pipeline. 
    62  
    63  ## See Also
    64  
    65  * [Pipeline](../user-guide/pipeline.md):
    66    Overview of what a "pipeline" is
    67  * [`->` Arrow Pipe](../parser/pipe-arrow.md):
    68    Pipes STDOUT from the left hand command to STDIN of the right hand command
    69  * [`=>` Generic Pipe](../parser/pipe-generic.md):
    70    Pipes a reformatted STDOUT stream from the left hand command to STDIN of the right hand command
    71  * [`?` STDERR Pipe](../parser/pipe-err.md):
    72    Pipes STDERR from the left hand command to STDIN of the right hand command (DEPRECATED)
    73  * [`runmode`](../commands/runmode.md):
    74    Alter the scheduler's behaviour at higher scoping level
    75  * [`try`](../commands/try.md):
    76    Handles non-zero exits inside a block of code
    77  * [`tryerr`](../commands/tryerr.md):
    78    Handles errors inside a block of code
    79  * [`trypipe`](../commands/trypipe.md):
    80    Checks for non-zero exits of each function in a pipeline
    81  * [`trypipeerr`](../commands/trypipeerr.md):
    82    Checks state of each function in a pipeline and exits block on error
    83  * [`unsafe`](../commands/unsafe.md):
    84    Execute a block of code, always returning a zero exit number
    85  * [`|` POSIX Pipe](../parser/pipe-posix.md):
    86    Pipes STDOUT from the left hand command to STDIN of the right hand command
    87  
    88  <hr/>
    89  
    90  This document was generated from [gen/user-guide/schedulers_doc.yaml](https://github.com/lmorg/murex/blob/master/gen/user-guide/schedulers_doc.yaml).