当前位置:网站首页>PM2 deploy nuxt3 JS project
PM2 deploy nuxt3 JS project
2022-06-24 08:56:00 【Haoyanfeng VIP】
Preface
as everyone knows ,nuxt3.js Is based on vue Development ssr,seo A good framework for the project , Then develop and complete the project , How to deploy nuxt The project is also quite important , Next, I will record how I deployed it during development .
I wrote an article before vue and ssr+nuxt.js Configure environment variables and pm2 Service deployment , These two blogs must be combined ...
This article only introduces the configuration environment variables in detail , But how to deploy it will pass by , Because there was little research at that time pm2, Just right now , Successfully researched and launched , This article describes in detail how to deploy .
First step : Package the project and deploy it to the server
npm run build:prod
Just submit the packaged file to the server
Our company adopts jekins Package and deploy the project automatically , Automatically execute commands after code submission , That's all right. .
The second step : Installation on server pm2
Remember to install globally , In this way, any command window opened on the server can be used , I just didn't have a global installation at the beginning , Lead to the use of pm2 Command not found at
npm install pm2 -g
The third step : Start the service
pm2 start ecosystem.config.js
// Then use the following command to see the list of started Services
pm2 list
If the service is online Indicating successful startup , At this time, check your own project in the browser , Normal access .
Here's a little puzzle to explain : The startup command I wrote in the last article is
pm2 start --env uat, But this command is written in this article , In fact, these two are the same , Because I have distinguished the environment before packaging , So just start the service directly at this time
Step four : Set automatic restart
The significance of this step is that when the server fails or restarts ,pm2 The service can restart automatically , You don't need to hit the command to restart every time the server hangs up pm2 service .
pm2 startup Set the server to automatically start the service after restart linux The server can directly execute , and windows The server needs to install the plug-ins below
- 1, Save the status of the started service list
// This step is essential
pm2 save
- 2, Global installation pm2-windows-startup
cnpm install pm2-windows-startup -g
- 3, Set up pm2-startup
pm2-startup install
After the above steps are set successfully , Restart the server , Then open the command line , Input
pm2 listCheck the service status ,
Then check whether the website can be accessed normally , Normal access means that the settings are successful .
Conclusion
Here we are ,pm2 Deploy nuxt The project was a success , Next, make a note of the commonly used pm2 command .
| command | purpose |
|---|---|
| pm2 list | View the list of started Services |
| pm2 restart nuxtjsDemo | Restart named nuxtjsDemo Service for |
| pm2 stop nuxtjsDemo | The termination name is nuxtjsDemo Service for |
| pm2 delete nuxtjsDemo | Delete the name nuxtjsDemo Service for |
| pm2 kill | Kill service |
| pm2 logs nuxtjsDemo | Check out the name nuxtjsDemo Service log of |
边栏推荐
- Background management of uniapp hot update
- 解决:模型训练时loss出现nan
- 1704. judge whether the two halves of a string are similar
- 110. 平衡二叉树-递归法
- One article explains in detail | those things about growth
- 阿里资深软件测试工程师推荐测试人员必学——安全测试入门介绍
- 用VNC Viewer的方式远程连接无需显示屏的树莓派
- The pie chart with dimension lines can set various parameter options
- Opencv maximum filtering (not limited to images)
- leetcode 1642. Furthest building you can reach
猜你喜欢

陆奇:我现在最看好这四大技术趋势

110. balanced binary tree recursive method

关于ETL看这篇文章就够了,三分钟让你明白什么是ETL

玄铁E906移植----番外0:玄铁C906仿真环境搭建

【LeetCode】415. 字符串相加

Why can ping fail while traceroute can

听说你还在花钱从网上买 PPT 模板?

疫情、失业,2022,我们高喊着摆烂和躺平!

uniapp 开发多端项目如何配置环境变量以及区分环境打包

What is the future development trend of Business Intelligence BI
随机推荐
Get screen width and height tool class
KaFormer个人笔记整理
Picture tools
Solving linear equations with MATLAB ax=b
The pie chart with dimension lines can set various parameter options
Liunx change the port number of vsftpd
520. 检测大写字母
One article explains in detail | those things about growth
Why can ping fail while traceroute can
orb slam build bug: undefined reference to symbol ‘_ ZN5boost6system15system_ categoryEv‘
阿里资深软件测试工程师推荐测试人员必学——安全测试入门介绍
【E325: ATTENTION】vim编辑时报错
原生小程序用画布制作海报,等比例缩放,和uniapp差不多就是写法有点不同
[team management] 25 tips for testing team performance management
GradScaler MaxClipGradScaler
Qingcloud based "real estate integration" cloud solution
K8s deployment of highly available PostgreSQL Cluster -- the road to building a dream
【MySQL从入门到精通】【高级篇】(一)字符集的修改与底层原理
What is graph neural network? Figure what is the use of neural networks?
数据中台:国内大厂中台建设架构集锦