# Automatic Restart

> 📷 Watching a config for changes requires an upgraded subscription
>
> Watching a config for changes is available with our Team and Enterprise plans. [View our plans](https://doppler.com/pricing?utm_medium=website\&utm_source=docs) or [book a demo](https://www.doppler.com/demo-cal?utm_medium=website\&utm_source=docs) for more details.

The Doppler CLI can automatically restart your process when your secrets change.

## Usage

To enable auto restart of your process, pass the `--watch` flag to the `doppler run` command.

```shell Shell
doppler run --watch -- ./your_command.sh
```

<Image align="center" width="80% " src="https://files.readme.io/dd5aeffbcc1b4cf1e73b4b589abfb6d72e4cc61e5f222dadbe3f5e7a3b9191c0-CleanShot_2024-10-11_at_11.55.21.gif" />

## Technical Details

Doppler's CLI strongly prioritizes the uptime of your application. Your process is only restarted once the latest secrets are successfully fetched. Additionally, your initial command is executed immediately, before the CLI attempts to watch for changes. This ensures that an inability to watch for changes does not prevent your process from starting.

The CLI's restart logic is as follows:

1. CLI receives message over long-lived HTTP connection indicating secrets have changed
2. CLI fetches the latest secrets
3. `SIGTERM` is sent to the originally started process
4. CLI waits up to 10 seconds for the process to exit
5. If process still hasn't exited, `SIGKILL` is sent
6. If using `--mount` flag, secrets file is remounted with the latest secrets
7. Originally provided command is re-run

## Limitations

When multiple instances of the CLI are watching the same Doppler config, they will all receive the latest secrets at roughly the same time. This effectively means that all processes will be restarted at the same time. This can result in downtime when used in production. For production use cases, it is recommended to instead use the [Doppler Kubernetes Operator](https://docs.doppler.com/docs/kubernetes-operator).