-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: wasm module hot reload #168
Conversation
Hi @zu1k, welcome to mosn community, Please sign Contributor License Agreement! After you signed CLA, we will automatically sync the status of this pull request in 3 minutes. |
deal with the case that wasm file was created after deleted
I'm trying to create a PR for If the PR merged, we can use a more convenient method to achieve wasm reload, see zu1k@e26d11b for the latest changes. |
Codecov Report
@@ Coverage Diff @@
## main #168 +/- ##
==========================================
- Coverage 60.24% 58.38% -1.86%
==========================================
Files 49 50 +1
Lines 2065 2146 +81
==========================================
+ Hits 1244 1253 +9
- Misses 700 772 +72
Partials 121 121
Continue to review full report at Codecov.
|
Cool,thanks for your contribution! |
@zu1k thank you for your contribute! |
What this PR does:
Let Layotto monitor whether the .wasm file has changed, and reload the .wasm file if there is a change.
Achieve the effect of dynamically replacing .wasm at runtime
Which issue(s) this PR fixes:
Fixes #165
Special notes for your reviewer:
I'm using https://github.com/fsnotify/fsnotify to monitor whether the specified .wasm file has changed. However I found events may be lost in some cases for the principle of fsnotify. The fsnotify is based on the file system and OS features. For example, on GNU/Linux, inotify is taking the info from the
inode
of the file, and not the file name. If a file is deleted and it is created again, it may have a different inode. I'm trying to watch its parent directory to deal with this case.When using
mv
to overwrite the wasm file, it willremove
the file first, thenrename
the origin file. In this case, fsnotify will lost the monitor when gotremove
event, resulting in subsequent failure to continue hot loading. We won't have this problem withcp
. I'm trying to solve this problem by rewatching the file when the event isremove
and file still exists.What's more, I found that mosn encapsulates wasmer but doesn't provide the ability to reload a wasm module, so currently I reload by uninstalling first and then adding, I don't think this is a good way to do it, if possible I would like someone to expose the method by create a PR for mosn.
Does this PR introduce a user-facing change?:
NONE