node.js - 将 azure 应用程序服务与 webpack+nodejs 结合使用,无需长时间部署中断

标签 node.js azure webpack azure-web-app-service

我尝试将 webpack 与我的(相当大的)NodeJS 应用程序一起使用,并使用 Git 持续部署部署为 Windows Azure 应用服务。

我自定义了 kudu deploy.sh 脚本来运行 webpack,但在 Azure 应用服务上进行 webpack 需要几分钟的时间,并且该应用在此期间不可用。在我的开发笔记本电脑上,运行 webpack 只需要大约 30 秒(我可以接受作为部署中断时间),但我猜测使用 SSD 的笔记本电脑会使运行速度更快?

如果我使用部署脚本,我只需在我的开发计算机上运行 webpack 并将结果推送到服务器,但我使用 git 进行持续部署,并且我不想不断提交 -将 webpack 生成的代码更改为 Git 存储库。

有没有办法在部署时使用基于 Azure 应用服务的 NodeJS 应用程序运行 webpack-on-deploy,而不会出现如此长的中断时间?

最佳答案

与其减少部署中断时间,不如尝试利用部署槽来防止应用在此期间不可用。

根据 Azure 的文档,

Deploying a web app to a slot first and swapping it into production ensures that all instances of the slot are warmed up before being swapped into production. This eliminates downtime when you deploy your web app. The traffic redirection is seamless, and no requests are dropped as a result of swap operations. This entire workflow can be automated by configuring Auto Swap when pre-swap validation is not needed.

如何向Web应用添加部署槽,请引用https://learn.microsoft.com/en-us/azure/app-service-web/web-sites-staged-publishing了解详情。

关于node.js - 将 azure 应用程序服务与 webpack+nodejs 结合使用,无需长时间部署中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41050429/

相关文章:

c# - azure 成员(member)资格System.Data.SqlClient.SqlException : Login failed for user '{your_username}' in Azure

azure - 微服务架构中的数据库位置

javascript - NodeJS 有什么办法可以防止这个错误吗?

node.js - Node : What's the most efficient way to read the last X bytes of a very large file (+1GB)?

Azure APIM 在一个实例中设置多个环境

javascript - 如何使用 Node.js 在非常简单的 JS 文件中编辑对象

node.js - 使用 webpack 时 Node 找不到模块 "fs"

reactjs - 使用 babel polyfill 后,bundle.js 仍然包含箭头函数和默认参数

javascript - Node 异步控制流程

javascript - 在 phantom.js 中显示鼠标光标