Skip to content

Conversation

@dfangl
Copy link
Member

@dfangldfangl commented Dec 7, 2022

Motivation

We want to provide hot reloading to be able to mount a volume into the container and see changes as they happen. For this, once a change happens, we have to reset the infrastructure, to support reloading (for example, a loaded python module will not change if the source changes, we have to reload it / restart the interpreter).

Changes

  • Add recursive filewatcher for the /var/task folder, to be alerted if something changes
  • Add a debounced function to reload 500ms after last file change (to prevent too many restarts due to massive file changes)

Todos

  • Check functionality on windows and mac, and add polling mode if necessary
  • Add separate env variables to watch /var/task and /opt respectively? Or a even better, a list of to-be-watched directories.

Copy link
Member

@dominikschubertdominikschubert left a comment

Choose a reason for hiding this comment

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

Looking forward to this feature! 😁

Added a few nits and suggestions.

Especially the main logic block in RunFileWatcher would benefit a lot from deconstructing it into smaller functions and introducing a struct for the filewatcher.

A few other suggestions for now:

  • separate the debounce from the actual consumption/processing of the changes for more clarity (e.g. the debounce itself could be a wrapper around the channel)
  • prefer passing a context instead of a channel for signaling exit/done

Copy link
Member

@dominikschubertdominikschubert left a comment

Choose a reason for hiding this comment

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

small nit/suggestion, otherwise LGTM

@dfangldfangl marked this pull request as ready for review December 13, 2022 16:19
@dfangldfangl merged commit afe23d0 into localstackDec 13, 2022
@dfangldfangl deleted the hot-reloading branch December 13, 2022 16:56
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@dfangl@dominikschubert