Skip to content

Commit

Permalink
add note in Settings on using WatchFiles on WSL (encode#1647)
Browse files Browse the repository at this point in the history
* 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 <samcolvin@gmail.com>

* add a link to watchfiles doc

* Update docs/settings.md

* Use tip admonition for watchfiles env variable

Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
  • Loading branch information
3 people committed Oct 29, 2022
1 parent 2eeebac commit 325740f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docs/settings.md
Expand Up @@ -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 <glob-pattern>` - 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 <glob-pattern>` - 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 <int>` - Use multiple worker processes. Defaults to the `$WEB_CONCURRENCY` environment variable if available, or 1.
Expand Down

0 comments on commit 325740f

Please sign in to comment.