X Tutup
Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

dev: add live-reload capability#13718

Merged
simonrw merged 5 commits intomainfrom
ldr-live-reload
Feb 10, 2026
Merged

dev: add live-reload capability#13718
simonrw merged 5 commits intomainfrom
ldr-live-reload

Conversation

@simonrw
Copy link
Contributor

@simonrw simonrw commented Feb 9, 2026

Motivation

While using the localstack.dev.run command, it is quite frustrating to have to restart LocalStack on code changes. Even by sending an external signal to the container is slow. A lot of projects include a live reload mode, where filesystem changes trigger a restart of the application server. What if LocalStack had this feature?!

Changes

  • add --live-reload flag
  • add watchdog package (cross platform for file system change events) that monitors files to dev dependencies (not shipped in the container)
  • on changes to *.py files, restart the PID1 inside the localstack container which re-reads file contents from the file system

Notes

Unfortunately I was not able to simply run make upgrade-pinned-dependencies since I got the error:

Traceback (most recent call last):
  File "/Users/simon/work/localstack/localstack/.venv/bin/pip-compile", line 6, in <module>
    sys.exit(cli())
             ~~~^^ File "/Users/simon/work/localstack/localstack/.venv/lib/python3.13/site-packages/click/core.py", line 1485, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/Users/simon/work/localstack/localstack/.venv/lib/python3.13/site-packages/click/core.py", line 1406, in main
    rv = self.invoke(ctx)
  File "/Users/simon/work/localstack/localstack/.venv/lib/python3.13/site-packages/click/core.py", line 1269, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/work/localstack/localstack/.venv/lib/python3.13/site-packages/click/core.py", line 824, in invoke
    return callback(*args, **kwargs)
  File "/Users/simon/work/localstack/localstack/.venv/lib/python3.13/site-packages/click/decorators.py", line 34, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/simon/work/localstack/localstack/.venv/lib/python3.13/site-packages/piptools/scripts/compile.py", line 475, in cli
    prereleases=repository.finder.allow_all_prereleases or pre,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PackageFinder' object has no attribute 'allow_all_prereleases'

There seems to be a mismatch with pip versions (26 is not yet supported by pip-compile it seems, see #13674) however this PR only pins pip to !=26 but 26.0.1 has been released.

Also the version of ruff gets updated after running make upgrade-pinned-dependencies. This change does not belong in this PR so I have reverted the version of ruff in the requirements files back to its current value (0.14.14)

@simonrw simonrw added semver: patch Non-breaking changes which can be included in patch releases docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes labels Feb 9, 2026
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

Test Results - Preflight, Unit

23 114 tests  ±0   21 255 ✅ ±0   6m 23s ⏱️ +8s
     1 suites ±0    1 859 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit afdec93. ± Comparison against base commit d8ec7bc.

♻️ This comment has been updated with latest results.

@simonrw simonrw changed the title Dev; add live reload capability dev: add live-reload capability Feb 9, 2026
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

S3 Image Test Results (AMD64 / ARM64)

    2 files  ±0      2 suites  ±0   8m 12s ⏱️ +14s
  559 tests ±0    507 ✅ ±0   52 💤 ±0  0 ❌ ±0 
1 118 runs  ±0  1 014 ✅ ±0  104 💤 ±0  0 ❌ ±0 

Results for commit afdec93. ± Comparison against base commit d8ec7bc.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Feb 9, 2026

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 0s ⏱️ -6s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit afdec93. ± Comparison against base commit d8ec7bc.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Feb 9, 2026

Test Results - Alternative Providers

770 tests   362 ✅  20m 40s ⏱️
  2 suites  408 💤
  2 files      0 ❌

Results for commit 67778c7.

@github-actions
Copy link

github-actions bot commented Feb 9, 2026

Test Results (amd64) - Integration, Bootstrap

    5 files      5 suites   2h 39m 56s ⏱️
5 623 tests 5 101 ✅ 521 💤 1 ❌
5 629 runs  5 101 ✅ 527 💤 1 ❌

For more details on these failures, see this check.

Results for commit afdec93.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Feb 9, 2026

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   2h 0m 28s ⏱️ + 2m 20s
5 202 tests ±0  4 851 ✅ ±0  351 💤 ±0  0 ❌ ±0 
5 204 runs  ±0  4 851 ✅ ±0  353 💤 ±0  0 ❌ ±0 

Results for commit afdec93. ± Comparison against base commit d8ec7bc.

♻️ This comment has been updated with latest results.

@simonrw simonrw force-pushed the ldr-live-reload branch 3 times, most recently from 4d75d90 to af7f473 Compare February 9, 2026 13:19
@simonrw simonrw marked this pull request as ready for review February 9, 2026 14:35
@simonrw simonrw requested a review from thrau February 9, 2026 14:36
Copy link
Member

@alexrashed alexrashed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Really cool feature for the dev script!
The general upgrade of the lock file contains a lot of different stuff. With pip-tools it's a bit tedious right now to only add a single dependency, but it would be possible to do so with

pip-compile --strip-extras --upgrade-package "<package>==<version>" --extra <extra> -o requirements-<extra>.txt pyproject.toml


rule = Rule(f"Interactive session with {container_id[:12]} 💻")
console.print(rule)
live_reload_event = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Maybe rename this event to indicate that it is used to stop the watch thread? I was a bit confused by the handling in finally initially before reading the watcher.py...

Copy link
Member

@thrau thrau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great stuff! love the watcher implementation using watchdog and the fairly simple reload mechanism.

maybe the only thing to mention somewhere explicitly (even if obvious to us) is that state is lost on every reload. i guess persistence could be a way around this :-)

…on source changes

Watches host-side mounted source directories for .py file changes and sends
SIGUSR1 to PID 1 inside the container, triggering the supervisor to restart
the runtime without requiring a full container restart.
@simonrw
Copy link
Contributor Author

simonrw commented Feb 10, 2026

The failing test is unrelated

@simonrw simonrw merged commit 9ac6140 into main Feb 10, 2026
46 of 48 checks passed
@simonrw simonrw deleted the ldr-live-reload branch February 10, 2026 18:28
simonrw added a commit that referenced this pull request Feb 12, 2026
# Motivation

In #13718 we added live reload support to the `localstack.dev.run` script, however the additional dependency added (`watchdog`) was added to the `dev` extras section.

This section is not installed with our Pro setup make targets, or at least not everyone installs _this_ repo with the `dev` target, meaning that people who were using `localstack.dev.run` got an import error.

# Changes

Defer import of the module that itself imports `watchdog` so it is only required for people who actually want to use the `--live-reload` flag. This at least means a fewer number of people will be directly affected, and it is clearer what the issue is in this case.

In addition, a PR to the Pro repo will correct the packaging process so `localstack[dev]` is installed with our `test` dependencies, which is a very common install target for developers.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes semver: patch Non-breaking changes which can be included in patch releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup