Debian Codegraph @

testing/web-platform/tests/tools/third_party/websockets/docs/howto/autoreload.rst

raw
1 Reload on code changes
2 ======================
3
4 When developing a websockets server, you may run it locally to test changes.
5 Unfortunately, whenever you want to try a new version of the code, you must
6 stop the server and restart it, which slows down your development process.
7
8 Web frameworks such as Django or Flask provide a development server that
9 reloads the application automatically when you make code changes. There is no
10 such functionality in websockets because it's designed for production rather
11 than development.
12
13 However, you can achieve the same result easily.
14
15 Install watchdog_ with the ``watchmedo`` shell utility:
16
17 .. code-block:: console
18
19 $ pip install 'watchdog[watchmedo]'
20
21 .. _watchdog: https://pypi.org/project/watchdog/
22
23 Run your server with ``watchmedo auto-restart``:
24
25 .. code-block:: console
26
27 $ watchmedo auto-restart --pattern "*.py" --recursive --signal SIGTERM \
28 python app.py
29
30 This example assumes that the server is defined in a script called ``app.py``.
31 Adapt it as necessary.