More articles
preface
Taking advantage of the existing Ali cloud server, I deployed the low code platform I had earlier, and recorded the changes of the low code after deployment
Front-end resources are still on the code cloud, Github network can not hold, web git address: gitee.com/xwei111/les…
Project Experience Address
The front-end deployment
The Jenkins deployment has been described in the previous post, so it is ok to follow the steps, not to say more
Cross domain
The old
// Start on the Node side
res.header("Access-Control-Allow-Origin"."*");
Copy the code
new
// Production ngXIN is configured with reverse proxy
location ^~/lesscode/ {
proxy_pass http:/ / 47.98.126.233:3000;
}
// Develop the webpakc proxy locally
// baseUrl, etc
// Upload images and other resource address modification
devServer: {
proxy: {
"/lesscode": {
target: "http://47.98.126.233:3000".changeOrigin: true,,}}}Copy the code
The database
The old
Previously, the MongoDB Atlas online database was used
const mongodbUrl = `mongodb+srv://xxx:[email protected]/myFirstDatabase?retryWrites=true&w=majority`
Copy the code
new
After the Node server is deployed, database query often fails and the query is slow. Therefore, install mongodb on Linux
- The installation
Port 27017 by default. Use service to start, stop, restart, and view the status
apt-get install mongodb
/ / links mongo
mongo
// monggodb related commands
use [dbName]
show dbs
show collections
db.createCollection([name], [options])
Copy the code
- link
// localhost indicates the current Linux IP address
const mongodbUrl = `mongodb://localhost:27017/lesscode`
Copy the code
Node Service Deployment
Node is also deployed using Jenkins, and the steps are as follows:
linux
Create it in the root directorywww
Folder, here asnode
Service Deployment Address- configuration
jenkins
, most andweb
If the end configuration is the same, delete itbuild
andAfter the build
operation - in
Build environment
theSend files or execute commands over SSH after the build runs
Add the following script to:
cd /www/lesscode-server/
rm -rf *
cp -r /var/lib/jenkins/workspace/lesscode-server/* /www/lesscode-server/
cd /www/lesscode-server/
cnpm install
Copy the code
- Click on the
Build immediately
Can be
For the time being, it is such a plan, and we can optimize it when we know a better one
pm2
- The installation
npm install pm2 -g
// Pm2 related commands
pm2 list
pm2 stop xx
pm2 start xx
pm2 restart xx
Copy the code
- Starting the Node Service
// Enable watch to restart pM2 automatically if code changes during deployment
pm2 start ./bin/www --watch
Copy the code
conclusion
There are so many temporary changes, and the subsequent improvements are in the supplementary document