first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1 @@
aba93b85-5030-4811-80eb-f2659aba7026

View File

@@ -0,0 +1,26 @@
const app = require('express')(),
exec = require('child_process').execFile;
app.post('/pull', (req, res) => {
exec('pull.sh', (err, stdout, stderr) => {
if (err) {
console.log(`命令执行错误:${err}`)
res.json({
title: 'error',
message: err.message
})
} else {
console.log("命令执行成功:");
console.log(stdout);
res.json({
title: 'success',
})
}
});
})
app.listen(1314, () => {
console.log('Node.js自动部署运行在: 1314')
})

View File

@@ -0,0 +1,15 @@
{
"name": "pull",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "pm2 start index.js --name pull --watch -i max"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
}
}

View File

@@ -0,0 +1,32 @@
#!/bin/bash
# 项目路径
jar_path=/root/moehu-backend/
#编译好的jar名称
jar_name=back-0.0.1-SNAPSHOT.jar
#进入指定项目路径
cd ${jar_path}
echo ------
pwd
echo ------
#获取运行编译好的进程ID,便于我们在重新部署项目的时候先杀掉以前的进程
pid=$(cat /root/moehu-backend/moehu.pid)
# 拉取代码,编译打包
git pull && mvn clean package -Dmaven.test.skip=true
echo ------
echo ${pid}
echo ------
#杀掉以前可能启动的项目进程
kill -9 ${pid}
#启动jar,指定SpringBoot的profiles为test,后台启动
java -jar ${jar_name} &
#将进程ID存入到shaw-web.pid文件中
echo $! > /root/moehu-backend/moehu.pid