javascript - How to 'npm run build' on the server regularly
问题描述
My webpage doesn't update contents too often, and users don't necessarily need to get the latest contents. So most pages are generated at server side, and serves static pages.
However, there will be database update. That should be visible on the web page. So I want how to 'npm run build' regularly while my server serves stably. How do I do that?
解决方案
The first thing that comes to mind for "regular" tasks that will be simple and won't require much setup is a corn job. You can add 'npm run build'(obliviously pointing to the right directory) to crontab with any schedule you want. Here's a link with samples on how to setup cron.
But as you need to build your app and even run DB updates, it will be much safer and better to use CI solution. There are hundreds of them but my advice is to use Buddy. It has a free plan and super easy to work with. With Buddy you can set up a pipeline that will SSH in your server and do the job. Or you can set up pipelines that will do all the actions at Buddy CI and then upload compiled files to the server.
Also, if we'd know what exactly 'npm run build' does, it will be easier to point for a more detailed answer.
推荐阅读
- exception - Informix 存储过程通用异常处理
- java - 更新产品数量后总价不正确
- json - 将 pandas.df 转换为这种特定的 JSON 格式
- reactjs - 在 React 中的 TypeScript 中打开和关闭对话框的状态
- rest - 在 RestAssured 中关闭连接的理想方式?
- c# - 我如何(优雅地)从内部关闭工作人员服务?
- android - 应用终止后立即处理应用内更新
- css - 如何使用 dash-bootstrap 将标题文本垂直和水平居中
- tensorflow - tf.layers.batch_normalization 中不同轴的任何用例?
- javascript - 如何通过 vscode 扩展命令激活文档?