当前位置:网站首页>pm2 static file service
pm2 static file service
2022-08-10 14:54:00 【choukin】
Respect individual survival experience,Connect independent thinking ability,Bridging the boundaries between knowledge and ability ———— 《我的二本学生》
通过 http The protocol serves static files
PM2 可以通过命令 pm2 serve
Enable the static file serving function.It supports access to multiple raw files provided in a specified folder,Or as a single page application.
CLI
使用简单的命令,通过httpto serve static files(like a front-end app)
pm2 serve <path> <port>
默认端口是8080
如果没有指定<path>
The current folder will be used.It can also be used like any other app--name
或者 --watch
单页面应用:All requests are redirected to index.html
使用--spa
option to redirect all requests to index.html
pm2 serve --spa
使用配置文件
// ecosystem.config.js
module.exports = {
apps : [{
script:"serve",
env:{
PM2_SERVE_PATH:'.',
PM2_SERVE_PORT:8080,
PM2_SERVE_SPA: true,
PM2_SERVE_HOMEPAGE:'./index.html',
}
}]
}
Execute the following command and access http://localhost:8080
pm2 start ecosystem.config.js
Access rights are set by using a password
To protect access to public files you can use the following command
pm2 serve --basic-auth-username <username> --basic-auth-password <password>
配置文件方式
// ecosystem.config.js
module.exports = {
script:"serve",
env:{
PM2_SERVE_PATH:'.',
PM2_SERVE_PORT:8080,
PM2_SERVE_SPA:'./index.html',
PM2_SERVE_BASIC_AUTH: 'true',
PM2_SERVE_BASIC_AUTH_USERNAME: 'example-login',
PM2_SERVE_BASIC_AUTH_PASSWORD: 'example-password'
}
}
边栏推荐
- 字节终面:CPU 是如何读写内存的?
- MySQL - storage engine for databases
- redhat替换yum源时redhat.repo无法删除或无法禁用的问题解决方法
- Do not access Object.prototype method ‘hasOwnProperty‘ from target object....
- Boss raises salary!Look at my WPF Loading!!!
- Parallels 将扩展桌面平台产品,以进一步改善在 Mac 上运行 Windows 的用户体验和工作效率
- pm2之静态文件服务
- laravel throws the error to Dingding
- 解读STEAM教育中的表现性评价
- $‘\r‘: command not found
猜你喜欢
关于已拦截跨源请求CORS 头缺少 ‘Access-Control-Allow-Origin‘问题解决
[Semantic Segmentation] DeepLab Series
laravel 抛错给钉钉
机器学习总结(一)
中学数学建模书籍及相关的视频等(2022.08.09)
List集合
【语义分割】DeepLab系列
强意识 压责任 安全培训筑牢生产屏障
Do not access Object.prototype method ‘hasOwnProperty‘ from target object....
Azure IoT Partner Technology Empowerment Workshop: IoT Dev Hack
随机推荐
antd组件中a-modal设置固定高度,内容滚动显示
fatal error C1083 Unable to open include file 'io.h' No such file
640. Solving Equations: Simple Simulation Problems
Websocket realizes real-time change of chart content
Unfinished mathematics test paper ----- test paper generator (Qt includes source code)
SWIG教程《四》-go语言的封装
MySQL Principle and Optimization: Update Optimization
使用mysq语句操作数据库
Digital Collection Platform System Development Practice
win2012安装Oraclerac失败
Classifying irises using decision trees
The a-modal in the antd component is set to a fixed height, and the content is scrolled and displayed
程序员=加班??——掌握时间才能掌握人生
MySQL 原理与优化:Update 优化
PyTorch 多机多卡训练:DDP 实战与技巧
Do not access Object.prototype method ‘hasOwnProperty‘ from target object....
XML基本学习
《论文阅读》PLATO: Pre-trained Dialogue Generation Model with Discrete Latent Variable
leetcode 739. Daily Temperatures Daily Temperatures (Moderate)
2022-08-10日报: Swin Transformer作者曹越加入智源,开展视觉基础模型研究