From 325740f07f1e015807d1a9ba0e4014b9b4d86dd3 Mon Sep 17 00:00:00 2001 From: danroozemond <62466501+danroozemond@users.noreply.github.com> Date: Wed, 14 Sep 2022 18:54:36 +0200 Subject: [PATCH] add note in Settings on using WatchFiles on WSL (#1647) * add note in Settings on using WatchFiles on WSL * Update docs/settings.md Adopt suggested text change from PR#1647 Co-authored-by: Samuel Colvin * add a link to watchfiles doc * Update docs/settings.md * Use tip admonition for watchfiles env variable Co-authored-by: Samuel Colvin Co-authored-by: Marcelo Trylesinski --- docs/settings.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/settings.md b/docs/settings.md index 09a3db5d50..c40905f45a 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -38,11 +38,18 @@ If Uvicorn _cannot_ load [watchfiles](https://pypi.org/project/watchfiles/) at r ### Reloading with watchfiles -For more nuanced control over which file modifications trigger reloads, install `uvicorn[standard]`, which includes watchfiles as a dependency. Alternatively, install [watchfiles](https://pypi.org/project/watchfiles/) where Uvicorn can see it. This will enable the following options (which are otherwise ignored). +For more nuanced control over which file modifications trigger reloads, install `uvicorn[standard]`, which includes watchfiles as a dependency. Alternatively, install [watchfiles](https://pypi.org/project/watchfiles/) where Uvicorn can see it. + +Using Uvicorn with watchfiles will enable the following options (which are otherwise ignored). * `--reload-include ` - Specify a glob pattern to match files or directories which will be watched. May be used multiple times. By default the following patterns are included: `*.py`. These defaults can be overwritten by including them in `--reload-exclude`. * `--reload-exclude ` - Specify a glob pattern to match files or directories which will excluded from watching. May be used multiple times. By default the following patterns are excluded: `.*, .py[cod], .sw.*, ~*`. These defaults can be overwritten by including them in `--reload-include`. +!!! tip + When using Uvicorn through [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux), you might + have to set the `WATCHFILES_FORCE_POLLING` environment variable, for file changes to trigger a reload. + See [watchfiles documentation](https://watchfiles.helpmanual.io/api/watch/) for further details. + ## Production * `--workers ` - Use multiple worker processes. Defaults to the `$WEB_CONCURRENCY` environment variable if available, or 1.