-
Notifications
You must be signed in to change notification settings - Fork 14
/
makeJar.sh
68 lines (58 loc) · 2.08 KB
/
makeJar.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#! /bin/bash
### need edit Start
# mongodb 连接信息
mongodbAddress='127.0.0.1:27017'
mongodbDatabase='github-ams'
mongodbUsername='vpi'
mongodbPassword='LYyVKh7spO7hzDLv'
# 后端接口地址 spring project url prefix
prodApiUrl='http://www.whcj.press:11111'
# 谷歌插件下载地址
chromePluginDownloadUrl='http://www.whcj.press/vpiChromePlugin.zip'
# 项目根目录
projectDir='/opt/project/vpi/'
# jar存放目录
jarSaveDir='/usr/local/'
### need edit End
if [ "$projectDir" = "" ] ;then
echo "Missing parameter: projectDir!"
return
fi
if [ "$jarSaveDir" = "" ] ;then
echo "Missing parameter: jarSaveDir!"
return
fi
# git pull
cd ${projectDir} || exit
git fetch --all
git reset --hard develop
git pull
# replace parameter
sed -i "s|\$mongodbAddress|${mongodbAddress}|g" ${projectDir}ams/src/main/resources/application-prod.yml
sed -i "s|\$mongodbDatabase|${mongodbDatabase}|g" ${projectDir}ams/src/main/resources/application-prod.yml
sed -i "s|\$mongodbUsername|${mongodbUsername}|g" ${projectDir}ams/src/main/resources/application-prod.yml
sed -i "s|\$mongodbPassword|${mongodbPassword}|g" ${projectDir}ams/src/main/resources/application-prod.yml
sed -i "s|\$prodApiUrl|${prodApiUrl}|g" ${projectDir}front/.env.production
sed -i "s|\$chromePluginDownloadUrl|${chromePluginDownloadUrl}|g" ${projectDir}front/.env.production
# build
cd front || exit
npm cache clean --force
npm config set registry http://registry.npmjs.org/
rm -rf package-lock.json
npm install
npm run build
cd ${projectDir}chromePlugin && zip -r vpiChromePlugin.zip ./*
cd ${projectDir}ams && mvn clean package -DskipTests
# close old
appPid=$(netstat -ntlp | grep 11111 | awk '{print $7}' | head -1 | grep '[0-9]\+' -o)
if [ "$appPid" != "" ] ;then
kill "${appPid}"
echo "killed ${appPid}"
sleep 15s
fi
# move to nginx file & start
mv ${projectDir}chromePlugin/vpiChromePlugin.zip ${projectDir}front/dist/
mv ${projectDir}ams/target/ams.jar ${jarSaveDir}
cd ${jarSaveDir} || exit
nohup java -jar -XX:+HeapDumpOnOutOfMemoryError ${jarSaveDir}ams.jar > vpiNohup.out 2>&1 &
tail -f ${jarSaveDir}vpiNohup.out