Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
L
loit-build-common
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
loit-Infrastructure
loit-build-common
Commits
5cef0135
提交
5cef0135
authored
5月 22, 2021
作者:
chenshiying
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[新增] 部署脚本更新
上级
185f74e2
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
226 行增加
和
47 行删除
+226
-47
READEME.md
loit-build-component/loit-build-deploy-env/READEME.md
+13
-2
GeneratorScript.java
...src/main/java/com/loit/common/script/GeneratorScript.java
+25
-0
DeployInfoDataDTO.java
...in/java/com/loit/common/script/dto/DeployInfoDataDTO.java
+16
-3
push_script.sh
...it-build-deploy-env/src/main/resources/bin/push_script.sh
+1
-3
copyNginxConfig.sh
.../main/resources/bin/server/10.0.120.36/copyNginxConfig.sh
+5
-0
nginx_portal_9527.conf
...bin/server/10.0.120.36/nginxConfig/nginx_portal_9527.conf
+18
-0
host_ip_push_script.txt
...env/src/main/resources/bin/server/host_ip_push_script.txt
+1
-1
deployInfo.xlsx
.../loit-build-deploy-env/src/main/resources/deployInfo.xlsx
+0
-0
bootstrap.ftl
...uild-deploy-env/src/main/resources/template/bootstrap.ftl
+1
-1
copyNginxConfig.ftl
...eploy-env/src/main/resources/template/copyNginxConfig.ftl
+4
-0
deploy-portal-web-sh.ftl
...-env/src/main/resources/template/deploy-portal-web-sh.ftl
+39
-20
deploy-web-sh-temp.ftl
...oy-env/src/main/resources/template/deploy-web-sh-temp.ftl
+49
-0
deploy-web-sh.ftl
...-deploy-env/src/main/resources/template/deploy-web-sh.ftl
+36
-17
nginx_config.ftl
...d-deploy-env/src/main/resources/template/nginx_config.ftl
+18
-0
没有找到文件。
loit-build-component/loit-build-deploy-env/READEME.md
浏览文件 @
5cef0135
...
...
@@ -81,11 +81,22 @@ pssh -h /home/soft/deploy/server/host_ip_skywalking.txt -i bash /usr/local/src/m
```
8、发送部署包
8、部署文件更新
发送最新部署文件
```
shell
sh push_script.sh
```
执行初始化 /home/soft 脚本
```
shell
pssh
-h
/home/soft/deploy/server/host_ip_push_script.txt
-i
bash /home/soft/initEnv.sh
```
执行拷贝 nginx 配置文件
```
shell
pssh
-h
/home/soft/deploy/server/host_ip_push_script.txt
-i
bash /home/soft/copyNginxConfig.sh
```
loit-build-component/loit-build-deploy-env/src/main/java/com/loit/common/script/GeneratorScript.java
浏览文件 @
5cef0135
...
...
@@ -73,10 +73,20 @@ public class GeneratorScript {
folder
.
mkdirs
();
}
String
nginxConfigDir
=
root_path_full
+
"\\"
+
grayVersionDataDTO
.
getFixedIp
()
+
"\\nginxConfig"
;
File
nginxConfigFolder
=
new
File
(
nginxConfigDir
);
if
(!
nginxConfigFolder
.
exists
())
{
nginxConfigFolder
.
mkdirs
();
}
String
filePath
=
fileDir
+
"\\initEnv.sh"
;
File
file
=
new
File
(
filePath
);
if
(!
file
.
exists
())
{
FileUtils
.
write
(
filePath
,
"#!/bin/bash "
);
//TODO
FileUtils
.
appendNewLine
(
filePath
,
"rm -rf /home/soft/*"
);
}
String
deployPath
=
grayVersionDataDTO
.
getDeployPath
();
...
...
@@ -87,6 +97,12 @@ public class GeneratorScript {
FileUtils
.
appendNewLine
(
filePath
,
"mkdir -p "
+
deployPath
+
"/logs"
);
}
}
String
nginxConfigShFileName
=
fileDir
+
"\\copyNginxConfig.sh"
;
String
nginxConfigShResult
=
FreeMarkerUtils
.
process
(
"copyNginxConfig.ftl"
,
null
);
FileUtils
.
write
(
nginxConfigShFileName
,
nginxConfigShResult
);
}
...
...
@@ -150,6 +166,7 @@ public class GeneratorScript {
String
deployPath
=
grayVersionDataDTO
.
getDeployPath
();
String
deployJar
=
grayVersionDataDTO
.
getDeployJar
();
String
serviceNameAbb
=
grayVersionDataDTO
.
getServiceNameAbb
();
String
nginxConfigName
=
grayVersionDataDTO
.
getNginxConfigName
();
if
(
StringUtils
.
isBlank
(
serviceName
))
{
...
...
@@ -174,6 +191,7 @@ public class GeneratorScript {
model
.
put
(
"deployPath"
,
deployPath
);
model
.
put
(
"deployJar"
,
deployJar
);
model
.
put
(
"serviceNameAbb"
,
serviceNameAbb
);
model
.
put
(
"nginxConfigName"
,
nginxConfigName
);
String
deployShFileName
=
fileDir
+
"\\deploy-"
+
serviceName
+
"-"
+
port
+
".sh"
;
String
deployShResult
=
FreeMarkerUtils
.
process
(
"deploy-web-sh.ftl"
,
model
);
...
...
@@ -182,5 +200,12 @@ public class GeneratorScript {
}
FileUtils
.
write
(
deployShFileName
,
deployShResult
);
if
(
StringUtils
.
isNotBlank
(
nginxConfigName
))
{
String
nginxName
=
root_path_full
+
"\\"
+
fixedIp
+
"\\nginxConfig"
+
"\\"
+
nginxConfigName
;
String
nginxConfigResult
=
FreeMarkerUtils
.
process
(
"nginx_config.ftl"
,
model
);
FileUtils
.
write
(
nginxName
,
nginxConfigResult
);
}
}
}
loit-build-component/loit-build-deploy-env/src/main/java/com/loit/common/script/dto/DeployInfoDataDTO.java
浏览文件 @
5cef0135
...
...
@@ -37,20 +37,25 @@ public class DeployInfoDataDTO implements Serializable {
private
String
port
;
@ApiModelProperty
(
value
=
"部署包名称"
)
@ExcelField
(
title
=
"部署包名称"
,
sort
=
6
)
@ExcelField
(
title
=
"部署包名称"
,
sort
=
7
)
private
String
deployJar
;
@ApiModelProperty
(
value
=
"前端子系统缩写"
)
@ExcelField
(
title
=
"前端子系统缩写"
,
sort
=
6
)
@ExcelField
(
title
=
"前端子系统缩写"
,
sort
=
8
)
private
String
serviceNameAbb
;
@ApiModelProperty
(
value
=
"spring.profiles.active"
)
@ExcelField
(
title
=
"spring.profiles.active"
,
sort
=
6
)
@ExcelField
(
title
=
"spring.profiles.active"
,
sort
=
9
)
private
String
springProfilesActive
;
@ApiModelProperty
(
value
=
"nginxConfigName"
)
@ExcelField
(
title
=
"nginxConfigName"
,
sort
=
10
)
private
String
nginxConfigName
;
public
String
getFixedIp
()
{
return
fixedIp
;
}
...
...
@@ -122,4 +127,12 @@ public class DeployInfoDataDTO implements Serializable {
public
void
setSpringProfilesActive
(
String
springProfilesActive
)
{
this
.
springProfilesActive
=
springProfilesActive
;
}
public
String
getNginxConfigName
()
{
return
nginxConfigName
;
}
public
void
setNginxConfigName
(
String
nginxConfigName
)
{
this
.
nginxConfigName
=
nginxConfigName
;
}
}
loit-build-component/loit-build-deploy-env/src/main/resources/bin/push_script.sh
浏览文件 @
5cef0135
...
...
@@ -3,9 +3,7 @@
[
!
-f
/root/.ssh/id_rsa.pub
]
&&
ssh-keygen
-t
rsa
-f
/root/.ssh/id_rsa &>/dev/null
while
read
line
;
do
user_name
=
`
echo
$line
|
cut
-d
" "
-f1
`
# 提取文件中的用户名
pass_word
=
`
echo
$line
|
cut
-d
" "
-f2
`
# 提取文件中的密码
ip
=
`
echo
$line
|
cut
-d
" "
-f3
`
# 提取文件中的ip
ip
=
`
echo
$line
|
cut
-d
" "
-f1
`
# 提取文件中的用户名
scp
-r
/home/soft/deploy/server/
$ip
/
*
root@
$ip
:/home/soft
...
...
loit-build-component/loit-build-deploy-env/src/main/resources/bin/server/10.0.120.36/copyNginxConfig.sh
0 → 100644
浏览文件 @
5cef0135
#!/bin/bash
\c
p
-rf
/home/soft/nginxConfig/ /usr/local/nginx/conf/conf.d.start/
loit-build-component/loit-build-deploy-env/src/main/resources/bin/server/10.0.120.36/nginxConfig/nginx_portal_9527.conf
0 → 100644
浏览文件 @
5cef0135
server
{
listen
9527
;
server_name
localhost
;
gzip
on
;
gzip_buffers
32
4
K
;
gzip_comp_level
6
;
gzip_min_length
100
;
gzip_types
application
/
javascript
text
/
css
text
/
xml
;
gzip_vary
on
;
location
/{
root
/
home
/
soft
/
loit
-
portal
-
web
-
9527
/;
try_files
$
uri
$
uri
/ /
index
.
html
;
index
index
.
html
;
}
}
loit-build-component/loit-build-deploy-env/src/main/resources/bin/server/host_ip_push_script.txt
浏览文件 @
5cef0135
root Kingsoft123 10.0.120.36
10.0.120.36 root
loit-build-component/loit-build-deploy-env/src/main/resources/deployInfo.xlsx
浏览文件 @
5cef0135
No preview for this file type
loit-build-component/loit-build-deploy-env/src/main/resources/template/bootstrap.ftl
浏览文件 @
5cef0135
spring.profiles.active=
prod${port
}
spring.profiles.active=
${springProfilesActive
}
spring.application.name=loit-${serviceName}
# Nacos \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0135\ufffd\u05b7
spring.cloud.nacos.config.server-addr=10.0.120.221:8848
...
...
loit-build-component/loit-build-deploy-env/src/main/resources/template/copyNginxConfig.ftl
0 → 100644
浏览文件 @
5cef0135
#!/bin/bash
\c
p
-rf
/home/soft/nginxConfig/ /usr/local/nginx/conf/conf.d.start/
loit-build-component/loit-build-deploy-env/src/main/resources/template/deploy-portal-web-sh.ftl
浏览文件 @
5cef0135
#!/bin/sh
params1
=
$1
command
=
$(
cat
updowncommand.txt
)
echo
'command:'
$command
if
[
-z
"
$1
"
]
;
then
command
=
'start'
if
[
-z
"
$
params
1
"
]
;
then
command
=
"start"
echo
'command reset value:'
$command
fi
PROCESS_ID
=
$(
netstat
-nlp
|
grep
9128|
awk
'{print $7}'
|
awk
-F
'[ / ]'
'{print $1}'
)
echo
'ProcessId: '
$PROCESS_ID
for
id
in
$PROCESS_ID
do
echo
'KILL_ID: '
$id
kill
-s
9
$id
done
if
[
"
$params1
"
=
"stop"
]
;
then
command
=
"stop"
echo
'command params value:'
$command
fi
nginxConf
=
"/
${
nginxConfigName
}
"
nginxPath
=
"/usr/local/nginx/"
startPath
=
$nginxPath
'conf/conf.d.start'
startConf
=
$startPath$nginxConf
stopPath
=
$nginxPath
'conf/conf.d.stop'
stopConf
=
$stopPath$nginxConf
echo
'startConf:'
$startConf
if
[
"
$command
"
=
"stop"
]
;
then
echo
'test'
if
[
-e
"
$startConf
"
]
;
then
echo
'copy to stop file'
mv
$startConf
$stopPath
fi
fi
if
[
"
$command
"
!=
"stop"
]
;
then
if
[
-e
"
$stopConf
"
]
;
then
echo
'copy to start file'
mv
$stopConf
$startPath
fi
cd
${
deployPath
}
rm
-rf
dist
rm
-rf
static
rm
-rf
vue-permission/static
unzip dist
*
.zip
cp
-r
dist/static static
cp
-r
dist/static vue-permission/static
rm
-rf
dist/
rm
-rf
${
serviceNameAbb
}
/
fi
mkdir
-p
${
serviceNameAbb
}
/dist
pid_file
=
$nginxPath
"logs/nginx.pid"
unzip dist
*
.zip
cp
-r
dist/
*
${
serviceNameAbb
}
/dist
cp
-r
dist/static
${
serviceNameAbb
}
/
if
[
!
-e
"
$pid_file
"
]
;
then
/usr/local/nginx/sbin/nginx
fi
#nohup ./node_modules/http-server/bin/http-server -p ${port} >/dev/null 2>&1 &
exit
if
[
-e
"
$pid_file
"
]
;
then
/usr/local/nginx/sbin/nginx
-s
reload
fi
loit-build-component/loit-build-deploy-env/src/main/resources/template/deploy-web-sh-temp.ftl
0 → 100644
浏览文件 @
5cef0135
#!/bin/sh
command
=
$(
cat
updowncommand.txt
)
echo
'command:'
$command
if
[
-z
"
$1
"
]
;
then
command
=
'start'
echo
'command reset value:'
$command
fi
nginxConf
=
"/
${
nginxConfigName
}
"
nginxPath
=
"/usr/local/nginx/"
startPath
=
$nginxPath
'conf/conf.d.start'
startConf
=
$startPath$nginxConf
stopPath
=
$nginxPath
'conf/conf.d.stop'
stopConf
=
$stopPath$nginxConf
echo
'startConf:'
$startConf
if
[
"
$command
"
=
"stop"
]
;
then
echo
'test'
if
[
-e
"
$startConf
"
]
;
then
echo
'copy to stop file'
mv
$startConf
$stopPath
fi
fi
if
[
"
$command
"
!=
"stop"
]
;
then
if
[
-e
"
$stopConf
"
]
;
then
echo
'copy to start file'
mv
$stopConf
$startPath
fi
fi
if
[
"
$command
"
=
"deploy"
]
;
then
cd
${
deployPath
}
rm
-rf
dist/
rm
-rf
${
serviceNameAbb
}
/
mkdir
-p
${
serviceNameAbb
}
/dist
unzip dist
*
.zip
cp
-r
dist/
*
${
serviceNameAbb
}
/dist
cp
-r
dist/static
${
serviceNameAbb
}
/
fi
pid_file
=
$nginxPath
"logs/nginx.pid"
if
[
!
-e
${
r
"
${
pid_file
}
"
}
]
;
then
/usr/local/nginx/sbin/nginx
fi
if
[
-e
${
r
"
${
pid_file
}
"
}
]
;
then
/usr/local/nginx/sbin/nginx
-s
reload
fi
loit-build-component/loit-build-deploy-env/src/main/resources/template/deploy-web-sh.ftl
浏览文件 @
5cef0135
#!/bin/sh
params1
=
$1
command
=
$(
cat
updowncommand.txt
)
echo
'command:'
$command
if
[
-z
"
$1
"
]
;
then
command
=
'start'
if
[
-z
"
$
params
1
"
]
;
then
command
=
"start"
echo
'command reset value:'
$command
fi
PROCESS_ID
=
$(
netstat
-nlp
|
grep
9128|
awk
'{print $7}'
|
awk
-F
'[ / ]'
'{print $1}'
)
echo
'ProcessId: '
$PROCESS_ID
for
id
in
$PROCESS_ID
do
echo
'KILL_ID: '
$id
kill
-s
9
$id
done
if
[
"
$params1
"
=
"stop"
]
;
then
command
=
"stop"
echo
'command params value:'
$command
fi
nginxConf
=
"/
${
nginxConfigName
}
"
nginxPath
=
"/usr/local/nginx/"
startPath
=
$nginxPath
'conf/conf.d.start'
startConf
=
$startPath$nginxConf
stopPath
=
$nginxPath
'conf/conf.d.stop'
stopConf
=
$stopPath$nginxConf
echo
'startConf:'
$startConf
if
[
"
$command
"
=
"stop"
]
;
then
echo
'test'
if
[
-e
"
$startConf
"
]
;
then
echo
'copy to stop file'
mv
$startConf
$stopPath
fi
fi
if
[
"
$command
"
!=
"stop"
]
;
then
cd
${
deployPath
}
if
[
-e
"
$stopConf
"
]
;
then
echo
'copy to start file'
mv
$stopConf
$startPath
fi
cd
${
deployPath
}
rm
-rf
dist/
rm
-rf
${
serviceNameAbb
}
/
mkdir
-p
${
serviceNameAbb
}
/dist
unzip dist
*
.zip
cp
-r
dist/
*
${
serviceNameAbb
}
/dist
cp
-r
dist/static
${
serviceNameAbb
}
/
#nohup ./node_modules/http-server/bin/http-server -p ${port} >/dev/null 2>&1 &
exit
fi
pid_file
=
$nginxPath
"logs/nginx.pid"
if
[
!
-e
"
$pid_file
"
]
;
then
/usr/local/nginx/sbin/nginx
fi
if
[
-e
"
$pid_file
"
]
;
then
/usr/local/nginx/sbin/nginx
-s
reload
fi
loit-build-component/loit-build-deploy-env/src/main/resources/template/nginx_config.ftl
0 → 100644
浏览文件 @
5cef0135
server{
listen ${port};
server_name localhost;
gzip on;
gzip_buffers 32 4K;
gzip_comp_level 6;
gzip_min_length 100;
gzip_types application/javascript text/css text/xml;
gzip_vary on;
location /{
root ${deployPath}/;
try_files $uri $uri/ /index.html;
index index.html;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论