first commit
This commit is contained in:
1
moehu/moehu-backend/pull/.pydio
Normal file
1
moehu/moehu-backend/pull/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
f933765a-86e1-4472-9040-0a18cdf1a664
|
||||
35
moehu/moehu-backend/pull/index.js
Normal file
35
moehu/moehu-backend/pull/index.js
Normal file
@@ -0,0 +1,35 @@
|
||||
const app = require('express')(),
|
||||
exec = require('child_process').execFile;
|
||||
|
||||
app.post('/pull', (req, res) => {
|
||||
exec('/root/moehu-backend/pull/pull.sh',{
|
||||
cwd: './',
|
||||
encoding: 'utf8',
|
||||
stdio: 'inherit'
|
||||
}, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.log(`命令执行错误 err:${err}`)
|
||||
console.log(`命令执行错误 stdout:${stdout}`)
|
||||
console.log(`命令执行错误 stderr :${stderr}`)
|
||||
res.json({
|
||||
title: 'error',
|
||||
message: err.message
|
||||
})
|
||||
} else {
|
||||
console.log(`命令成功错误 err:${err}`)
|
||||
console.log(`命令成功错误 stdout:${stdout}`)
|
||||
console.log(`命令成功错误 stderr :${stderr}`)
|
||||
res.json({
|
||||
title: 'success1',
|
||||
})
|
||||
}
|
||||
|
||||
res.json({
|
||||
title: 'success2',
|
||||
})
|
||||
});
|
||||
})
|
||||
|
||||
app.listen(1314, () => {
|
||||
console.log('Node.js自动部署运行在: 1314')
|
||||
})
|
||||
15
moehu/moehu-backend/pull/package.json
Normal file
15
moehu/moehu-backend/pull/package.json
Normal 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"
|
||||
}
|
||||
}
|
||||
20
moehu/moehu-backend/pull/pull.sh
Executable file
20
moehu/moehu-backend/pull/pull.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 项目路径
|
||||
jar_path=/root/moehu-backend
|
||||
#编译好的jar名称
|
||||
jar_name=/target/back-0.0.1-SNAPSHOT.jar
|
||||
|
||||
# 进入指定项目路径
|
||||
cd ${jar_path}
|
||||
|
||||
# 获取运行编译好的进程ID,便于我们在重新部署项目的时候先杀掉以前的进程
|
||||
pid=$(cat /root/moehu-backend/moehu.pid)
|
||||
|
||||
# 拉取代码,编译打包
|
||||
git pull && /root/maven/bin/mvn clean package -Dmaven.test.skip=true && kill -9 ${pid}
|
||||
|
||||
# nohup java -jar ${jar_path}${jar_name} --spring.profiles.active=prod &
|
||||
cd target/ && nohup java -jar back-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod &
|
||||
|
||||
echo $! > /root/moehu-backend/moehu.pid
|
||||
Reference in New Issue
Block a user