-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
59 lines (35 loc) · 850 Bytes
/
deploy.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
#!/usr/bin/env bash
set -e
PACKNAME=pack.zip
APP_DIR=/var/apps/com.draw.lyan
ZIP_TMP=/var/apps/tmpzip
# 本地先编译好
npm run build:client
zip -r $PACKNAME ./ -x "./node_modules/*" -x ".DS_Store" -x ".git/*" > /dev/null 2>&1
scp -r $PACKNAME root@draw.lyan.me:$ZIP_TMP
rm -rf $PACKNAME
ssh -tt root@draw.lyan.me << eeooff
PACKNAME=pack.zip
APP_DIR=/var/apps/com.draw.lyan
ZIP_TMP_PKG=/var/apps/tmpzip/$PACKNAME
cd /var/apps/tmpzip
rm -rf ./test
mkdir test
unzip $PACKNAME -d ./test
cd test
npm i
# npm run build:client
npm run build:server
# 删除之前的代码
rm -rf /var/apps/com.draw.lyan/*
# 移动新包到目标目录
cp -rf /var/apps/tmpzip/test/* $APP_DIR
rm -rf /var/apps/tmpzip/pack.zip
cd $APP_DIR
npm run stop:all
npm run start
sleep 3
curl localhost:8080/api/monitor/alive
exit
eeooff
echo '部署完成'