github.com/taylorchu/nomad@v0.5.3-rc1.0.20170407200202-db11e7dd7b55/website/source/docs/job-specification/restart.html.md (about)

     1  ---
     2  layout: "docs"
     3  page_title: "restart Stanza - Job Specification"
     4  sidebar_current: "docs-job-specification-restart"
     5  description: |-
     6    The "restart" stanza configures a group's behavior on task failure.
     7  ---
     8  
     9  # `restart` Stanza
    10  
    11  <table class="table table-bordered table-striped">
    12    <tr>
    13      <th width="120">Placement</th>
    14      <td>
    15        <code>job -> group -> **restart**</code>
    16      </td>
    17    </tr>
    18  </table>
    19  
    20  The `restart` stanza configures a group's behavior on task failure.
    21  
    22  ```hcl
    23  job "docs" {
    24    group "example" {
    25      restart {
    26        attempts = 3
    27        delay    = "30s"
    28      }
    29    }
    30  }
    31  ```
    32  
    33  ## `restart` Parameters
    34  
    35  - `attempts` `(int: <varies>)` - Specifies the number of restarts allowed in the
    36    configured interval. Defaults vary by job type, see below for more
    37    information.
    38  
    39  - `delay` `(string: "15s")` - Specifies the duration to wait before restarting a
    40    task. This is specified using a label suffix like "30s" or "1h". A random
    41    jitter of up to 25% is added to the delay.
    42  
    43  - `interval` `(string: <varies>)` - Specifies the duration which begins when the
    44    first task starts and ensures that only `attempts` number of restarts happens
    45    within it. If more than `attempts` number of failures happen, behavior is
    46    controlled by `mode`. This is specified using a label suffix like "30s" or
    47    "1h". Defaults vary by job type, see below for more information.
    48  
    49  - `mode` `(string: "delay")` - Controls the behavior when the task fails more
    50    than `attempts` times in an interval. For a detailed explanation of these
    51    values and their behavior, please see the [mode values section](#mode-values).
    52  
    53  ### `restart` Parameter Defaults
    54  
    55  The values for many of the `restart` parameters vary by job type. Here are the
    56  defaults by job type:
    57  
    58  - The default batch restart policy is:
    59  
    60      ```hcl
    61      restart {
    62        attempts = 15
    63        delay    = "15s"
    64        interval = "168h"
    65        mode     = "delay"
    66      }
    67      ```
    68  
    69  - The default non-batch restart policy is:
    70  
    71      ```hcl
    72      restart {
    73        interval = "1m"
    74        attempts = 2
    75        delay    = "15s"
    76        mode     = "delay"
    77      }
    78      ```
    79  
    80  
    81  ### `mode` Values
    82  
    83  This section details the specific values for the "mode" parameter in the Nomad
    84  job specification for constraints. The mode is always specified as a string
    85  
    86  ```hcl
    87  restart {
    88    mode = "..."
    89  }
    90  ```
    91  
    92  - `"delay"` - Instructs the scheduler to delay the next restart until the next
    93    `interval` is reached. This is the default behavior.
    94  
    95  - `"fail"` - Instructs the scheduler to not attempt to restart the task on
    96    failure. This mode is useful for non-idempotent jobs which are unlikely to
    97    succeed after a few failures.