chalice icon indicating copy to clipboard operation
chalice copied to clipboard

auto reload LocalDevServer on module change

Open aldegoeij opened this issue 9 years ago • 10 comments

Hello guys! Love the work on Chalice, makes life with API Gateway much easier.

What framework do you use for the LocalDevServer? Currently it does not auto reload on a change (save) of a module under development, which slows down development quite a bit.

Are you using bare BaseHTTPServer only? Is it easy to implement a reloader?

aldegoeij avatar Apr 28 '17 13:04 aldegoeij

We're using BaseHTTPServer. It should be possible to implement a reloader, not sure on how easy it would be, but I think it would be useful to have. Marking as feature request.

jamesls avatar Apr 28 '17 22:04 jamesls

+1.

It's easy to look for changed files using os.static and checking the st_mtime attribute. Like werkzeug[1]. The checking could be done in the LocalDevServer.serve_forever but instead of using the HTTPServer.serve_forever, the LocalDevServer.serve_forever would use the HTTPServer.handle_request inside a loop. Would this change have bad implications?

However I'm not sure of how to reload the application itself when we detect that a file changed. Just re-import everything?

[1] https://github.com/pallets/werkzeug/blob/368ccb07d097660156eb19a0ec2042bc53e68238/werkzeug/_reloader.py#L137

Marcelo-Theodoro avatar Sep 07 '17 16:09 Marcelo-Theodoro

wish I wasnt a python newb and could have helped with this :/

tzookb avatar Nov 20 '17 13:11 tzookb

+1

rapidoo avatar Nov 23 '17 14:11 rapidoo

+1

mlecoq avatar Jan 23 '18 14:01 mlecoq

While waiting for the feature, you can use watchdog and the command watchmedo:

watchmedo \
  auto-restart \
  --patterns="*.py" \
  --ignore-directories \
  --recursive \
  -- chalice local

Or other equivalents :grin: .

marcmillien avatar Feb 01 '18 23:02 marcmillien

@marcmillien Alas watchmedo auto-restart doesn't work on Windows... https://github.com/gorakhargosh/watchdog/issues/387 :-((

trickidicki avatar Feb 07 '18 04:02 trickidicki

+1, would love to have this.

juliensimon avatar May 05 '18 12:05 juliensimon

+1

cdalar avatar May 09 '18 23:05 cdalar

Implemented in https://github.com/aws/chalice/pull/846. This will go out in the next release.

jamesls avatar May 21 '18 19:05 jamesls