是否有一种方法可以在使用缓存时启用无服务器离线重新加载?
无服务器的离线非常慢,因此我启用了缓存以避免“冷启动”。现在,每个lambda的一切都很慢,但是对于任何代码更新,我需要重新启动开发设备。
我使用的
serverless offline --config ./serverless-offline.yml --allowCache --functionCleanupIdleTimeSeconds 10000
是可以设置和检测代码更新并清除整个缓存而无需重新启动的插件吗?甚至只是修改的lambda。
谢谢
Serverless Offline was very slow so I enabled caching to avoid "cold starts". Now everything is slow just one time per lambda but for any code updates, I need to restart the dev env.
I use
serverless offline --config ./serverless-offline.yml --allowCache --functionCleanupIdleTimeSeconds 10000
Is there a plugin that I can set up and detect code updates and clear the whole cache without restarting? Maybe even just the lambda that was modified.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,有了Nodemon,您可以取得相同的结果。
NPM I -D nodemon
,然后在您的开始脚本中:
“ start”:“ Nodemon -Exec无线电话离线”
。
最好的,
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,
您可以尝试减少
- functionCleanUpidletimeseconds
5 ,看看是否有帮助,10,000
非常高。...这意味着您将在10,000秒的时间内缓存近三个小时的源代码。
此外,您可能希望进行一些额外的调试,以确切查看速度下降的位置,在代码本身,DNS,主机机器等中,
编辑:我在使用Docker Image
Node时开始遇到错误:16
...所以我迁移到了Ubuntu 22.04,这解决了我的问题。You might try reducing
--functionCleanupIdleTimeSeconds
to5
and see if that helps,10,000
is pretty high.... meaning you'll be caching your source code for nearly three hours at 10,000 seconds.
Additionally, you may wish to do some extra debugging to see exactly where the slow-down is happening, in the code itself, DNS, host machine etc.
Edit: I started having errors with this while using Docker image
node:16
... so I migrated to Ubuntu 22.04 which solved my problem.这是您正在寻找的
无服务器脱机启动 - raloadhandler
This is what you are looking for
serverless offline start --reloadHandler