﻿`[defaults]` sets fallback values for every `[tasks.*]` and `[services.*]`. A
task or service that sets the key itself wins.

```toml title="runwisp.toml"
[defaults]
timeout       = "30m"
log_max_size  = "50mb"
keep_runs     = 100
healthy_after = "30s"
failures      = ["-missed"]

[tasks.heartbeat]
cron = "*/5 * * * *"
run  = "/usr/local/bin/heartbeat"   # uses every default above

[tasks.nightly-export]
cron    = "0 2 * * *"
timeout = "4h"                      # overrides the default
run     = "/usr/local/bin/export"
```

## Precedence

For each key, RunWisp uses the first of:

1. the value on the `[tasks.*]` / `[services.*]` table,
2. the value in `[defaults]`,
3. the built-in default.

An explicit `0` (or `"0s"`) on a task counts as set: `timeout = "0s"` turns off a
`[defaults]` timeout.

Two groups merge instead of replacing:

- `env`, `env_file`, `secrets`, `secrets_file` merge with the task's own; on the
  same key, the task wins. See
  [Environment & secrets](/configuration/tasks/#environment--secrets).
- `failures` is applied first, then the task's own `+`/`-` tokens change it. A
  bare list on the task replaces it.

## Keys

Each key means exactly what it means on a task or service. Follow the link for
type, default, and accepted values.

| Key                | Applies to | Reference                                                       |
| ------------------ | ---------- | --------------------------------------------------------------- |
| `timeout`          | both       | [`timeout`](/configuration/tasks/#timeout)                      |
| `graceful_stop`    | both       | [`graceful_stop`](/configuration/tasks/#graceful_stop)          |
| `stop_signal`      | both       | [`stop_signal`](/configuration/tasks/#stop_signal)              |
| `shell`            | both       | [`shell`](/configuration/tasks/#shell)                          |
| `failures`         | both       | [`failures`](/configuration/tasks/#failures)                    |
| `log_max_size`     | both       | [`log_max_size`](/configuration/tasks/#log_max_size)            |
| `log_on_full`      | both       | [`log_on_full`](/configuration/tasks/#log_on_full)              |
| `keep_runs`        | both       | [`keep_runs`](/configuration/tasks/#keep_runs)                  |
| `keep_for`         | both       | [`keep_for`](/configuration/tasks/#keep_for)                    |
| `env`              | both       | [`env`](/configuration/tasks/#env)                              |
| `env_file`         | both       | [`env_file`](/configuration/tasks/#env_file)                    |
| `secrets`          | both       | [`secrets`](/configuration/tasks/#secrets)                      |
| `secrets_file`     | both       | [`secrets_file`](/configuration/tasks/#secrets_file)            |
| `jitter`           | tasks      | [`jitter`](/configuration/tasks/#jitter)                        |
| `warn_after`       | tasks      | [`warn_after`](/configuration/tasks/#warn_after)                |
| `catch_up`         | tasks      | [`catch_up`](/configuration/tasks/#catch_up)                    |
| `healthy_after`    | services   | [`healthy_after`](/configuration/services/#healthy_after)       |
| `restart_attempts` | services   | [`restart_attempts`](/configuration/services/#restart_attempts) |
| `restart_delay`    | services   | [`restart_delay`](/configuration/services/#restart_delay)       |
| `restart_backoff`  | services   | [`restart_backoff`](/configuration/services/#restart_backoff)   |

A tasks-only key in `[defaults]` is ignored by services, and the other way round.

## What can't go here

Everything else is per task or daemon-wide:

- `cron`, `on_overlap`, `max_concurrent`, `max_queued`, the `retry_*` keys,
  `params`, `hook_tokens`, and `notify`. For a notifier on every task, use
  [`[notify] global_notifiers`](/configuration/notify/#global_notifiers).
- `[daemon]` (including `shutdown_timeout`), `[storage]`, and `[notify]`.
