Hello,
I just migrated to version 6+ and noticed that hot-reloading has been removed, but no instructions for how to add this on our own are provided.
This was one of my favorite features. Could your please provide some direction on how I would go about implementing hot-reloading??
Yes, with nodemon you can achieve the same results.
npm i -D nodemon
And then in your start script:
"start": "nodemon --exec serverless offline"
That should work.
Best,
"start": "nodemon --exec serverless offline"
Is this the same solution for reloading python files? I'm not familiar with the node ecosystem at all, I don't know what this start script you mention is.
Btw: hot reload is working for me in v6.1.5 but stopped somewhere between then and latest 6.4.0.
@dotorg-richard the python version would be "start": "nodemon -e py --exec sls offline"
this way nodemon will watch for your changes in python and restart
~@dherault I also noticed the hot-reloading was removed, but strangely it seems to work up to 6.1.5. If I switch to 6.1.7 everything seems cached and repeating executions are superfast but it does not pickup changes. 6.1.5 picks up any changes but for this reason is likely very much slower for repeats.~
~The nodemon solution kinda works.. but is always slower since the whole thing is restarted.~
~Looking at the diff, I can't seem to understand why the change happened at this specific place: https://github.com/dherault/serverless-offline/compare/v6.1.5...v6.1.7~
An optimal solution would be the caching speed of ^6.1.7 but with the behavior of 6.1.5 in case of changes are identified.
EDIT: Worth noticing that I'm using python.
EDIT2: Turns out this behavior is caused by https://github.com/dherault/serverless-offline/commit/138196aba470a7bcd2a650127af1d5d6da8018ab setting the default idle cleanup time to functionCleanupIdleTimeSeconds=60. Setting this value to a lower number will give the effect I was looking for.
@dotorg-richard
Btw: hot reload is working for me in v6.1.5 but stopped somewhere between then and latest 6.4.0.
See my previous reply. What happened here is the default value of functionCleanupIdleTimeSeconds. Passing this as a startup parameter brings back the old beahvior: sls offline start --functionCleanupIdleTimeSeconds 5 for 5 seconds idle cleanup.
Most helpful comment
Yes, with nodemon you can achieve the same results.
npm i -D nodemonAnd then in your start script:
"start": "nodemon --exec serverless offline"That should work.
Best,