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
185f74e2
提交
185f74e2
authored
5月 22, 2021
作者:
chenshiying
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[新增] 部署脚本生成
上级
68539540
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
170 行增加
和
24 行删除
+170
-24
.gitignore
.gitignore
+7
-0
GeneratorScript.java
...src/main/java/com/loit/common/script/GeneratorScript.java
+55
-6
DeployInfoDataDTO.java
...in/java/com/loit/common/script/dto/DeployInfoDataDTO.java
+27
-0
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
deploy-portal-web-sh.ftl
...-env/src/main/resources/template/deploy-portal-web-sh.ftl
+33
-0
deploy-sh.ftl
...uild-deploy-env/src/main/resources/template/deploy-sh.ftl
+14
-17
deploy-web-sh.ftl
...-deploy-env/src/main/resources/template/deploy-web-sh.ftl
+33
-0
没有找到文件。
.gitignore
浏览文件 @
185f74e2
...
...
@@ -4,6 +4,8 @@ target/
!**/src/main/**
!**/src/test/**
### STS ###
.apt_generated
.classpath
...
...
@@ -19,6 +21,7 @@ target/
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
...
...
@@ -29,3 +32,7 @@ build/
### VS Code ###
.vscode/
### project Code ###
**/src/main/resources/bin/serverTest/**
loit-build-component/loit-build-deploy-env/src/main/java/com/loit/common/script/GeneratorScript.java
浏览文件 @
185f74e2
...
...
@@ -50,7 +50,8 @@ public class GeneratorScript {
for
(
DeployInfoDataDTO
grayVersionDataDTO
:
grayVersionDataDTOList
)
{
buildInitEnv
(
grayVersionDataDTO
);
buildConfig
(
grayVersionDataDTO
);
buildBackendConfig
(
grayVersionDataDTO
);
buildFrontConfig
(
grayVersionDataDTO
);
}
}
catch
(
Exception
e
)
{
...
...
@@ -92,14 +93,15 @@ public class GeneratorScript {
/**
* 生成bootstrap.properties 及其 sh
*/
private
static
void
buildConfig
(
DeployInfoDataDTO
grayVersionDataDTO
)
throws
IOException
{
private
static
void
build
Backend
Config
(
DeployInfoDataDTO
grayVersionDataDTO
)
throws
IOException
{
String
serviceName
=
grayVersionDataDTO
.
getServiceName
();
String
fixedIp
=
grayVersionDataDTO
.
getFixedIp
();
String
port
=
grayVersionDataDTO
.
getPort
();
String
deployPath
=
grayVersionDataDTO
.
getDeployPath
();
String
deployJar
=
grayVersionDataDTO
.
getDeployJar
();
String
serviceNameAbb
=
grayVersionDataDTO
.
getServiceNameAbb
();
String
springProfilesActive
=
grayVersionDataDTO
.
getSpringProfilesActive
();
if
(
StringUtils
.
isBlank
(
serviceName
))
{
return
;
...
...
@@ -110,7 +112,8 @@ public class GeneratorScript {
return
;
}
String
fileDir
=
root_path_full
+
"\\"
+
fixedIp
+
"\\"
+
serviceName
+
"-"
+
port
;
String
folderName
=
deployPath
.
replace
(
"/home/soft/"
,
""
);
String
fileDir
=
root_path_full
+
"\\"
+
fixedIp
+
"\\"
+
folderName
;
File
folder
=
new
File
(
fileDir
);
if
(!
folder
.
exists
())
{
folder
.
mkdirs
();
...
...
@@ -123,15 +126,61 @@ public class GeneratorScript {
model
.
put
(
"serviceName"
,
serviceName
);
model
.
put
(
"deployPath"
,
deployPath
);
model
.
put
(
"deployJar"
,
deployJar
);
model
.
put
(
"serviceNameAbb"
,
serviceNameAbb
);
model
.
put
(
"springProfilesActive"
,
springProfilesActive
);
String
result
=
FreeMarkerUtils
.
process
(
"bootstrap.ftl"
,
model
);
FileUtils
.
write
(
bootstrapFileName
,
result
);
String
replace
=
serviceName
.
replace
(
"loit-"
,
"deploy-"
);
String
deployShFileName
=
fileDir
+
"\\"
+
replace
+
"-"
+
port
+
".sh"
;
String
deployShFileName
=
fileDir
+
"\\deploy-"
+
serviceName
+
"-"
+
port
+
".sh"
;
String
deployShResult
=
FreeMarkerUtils
.
process
(
"deploy-sh.ftl"
,
model
);
FileUtils
.
write
(
deployShFileName
,
deployShResult
);
}
/**
* 生成bootstrap.properties 及其 sh
*/
private
static
void
buildFrontConfig
(
DeployInfoDataDTO
grayVersionDataDTO
)
throws
IOException
{
String
serviceName
=
grayVersionDataDTO
.
getServiceName
();
String
fixedIp
=
grayVersionDataDTO
.
getFixedIp
();
String
port
=
grayVersionDataDTO
.
getPort
();
String
deployPath
=
grayVersionDataDTO
.
getDeployPath
();
String
deployJar
=
grayVersionDataDTO
.
getDeployJar
();
String
serviceNameAbb
=
grayVersionDataDTO
.
getServiceNameAbb
();
if
(
StringUtils
.
isBlank
(
serviceName
))
{
return
;
}
BackendFrontEnum
backendFrontType
=
BackendFrontEnum
.
getEnumByCode
(
grayVersionDataDTO
.
getBackendFrontType
());
if
(
BackendFrontEnum
.
BACKEND
.
equals
(
backendFrontType
))
{
return
;
}
String
folderName
=
deployPath
.
replace
(
"/home/soft/"
,
""
);
String
fileDir
=
root_path_full
+
"\\"
+
fixedIp
+
"\\"
+
folderName
;
File
folder
=
new
File
(
fileDir
);
if
(!
folder
.
exists
())
{
folder
.
mkdirs
();
}
Map
model
=
new
HashMap
();
model
.
put
(
"port"
,
port
);
model
.
put
(
"serviceName"
,
serviceName
);
model
.
put
(
"deployPath"
,
deployPath
);
model
.
put
(
"deployJar"
,
deployJar
);
model
.
put
(
"serviceNameAbb"
,
serviceNameAbb
);
String
deployShFileName
=
fileDir
+
"\\deploy-"
+
serviceName
+
"-"
+
port
+
".sh"
;
String
deployShResult
=
FreeMarkerUtils
.
process
(
"deploy-web-sh.ftl"
,
model
);
if
(
"portal-web"
.
equals
(
serviceName
))
{
deployShResult
=
FreeMarkerUtils
.
process
(
"deploy-portal-web-sh.ftl"
,
model
);
}
FileUtils
.
write
(
deployShFileName
,
deployShResult
);
}
}
loit-build-component/loit-build-deploy-env/src/main/java/com/loit/common/script/dto/DeployInfoDataDTO.java
浏览文件 @
185f74e2
...
...
@@ -40,6 +40,17 @@ public class DeployInfoDataDTO implements Serializable {
@ExcelField
(
title
=
"部署包名称"
,
sort
=
6
)
private
String
deployJar
;
@ApiModelProperty
(
value
=
"前端子系统缩写"
)
@ExcelField
(
title
=
"前端子系统缩写"
,
sort
=
6
)
private
String
serviceNameAbb
;
@ApiModelProperty
(
value
=
"spring.profiles.active"
)
@ExcelField
(
title
=
"spring.profiles.active"
,
sort
=
6
)
private
String
springProfilesActive
;
public
String
getFixedIp
()
{
return
fixedIp
;
}
...
...
@@ -95,4 +106,20 @@ public class DeployInfoDataDTO implements Serializable {
public
void
setDeployJar
(
String
deployJar
)
{
this
.
deployJar
=
deployJar
;
}
public
String
getServiceNameAbb
()
{
return
serviceNameAbb
;
}
public
void
setServiceNameAbb
(
String
serviceNameAbb
)
{
this
.
serviceNameAbb
=
serviceNameAbb
;
}
public
String
getSpringProfilesActive
()
{
return
springProfilesActive
;
}
public
void
setSpringProfilesActive
(
String
springProfilesActive
)
{
this
.
springProfilesActive
=
springProfilesActive
;
}
}
loit-build-component/loit-build-deploy-env/src/main/resources/deployInfo.xlsx
浏览文件 @
185f74e2
No preview for this file type
loit-build-component/loit-build-deploy-env/src/main/resources/template/bootstrap.ftl
浏览文件 @
185f74e2
spring.profiles.active=prod${port}
spring.application.name=${serviceName}
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
spring.cloud.nacos.config.namespace=05270cbf-5a81-4a23-a534-b59ba26f11d5
...
...
loit-build-component/loit-build-deploy-env/src/main/resources/template/deploy-portal-web-sh.ftl
0 → 100644
浏览文件 @
185f74e2
#!/bin/sh
command
=
$(
cat
updowncommand.txt
)
echo
'command:'
$command
if
[
-z
"
$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
[
"
$command
"
!=
"stop"
]
;
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
}
/
#nohup ./node_modules/http-server/bin/http-server -p ${port} >/dev/null 2>&1 &
exit
fi
loit-build-component/loit-build-deploy-env/src/main/resources/template/deploy-sh.ftl
浏览文件 @
185f74e2
#!/bin/sh
echo
'---------------kill_start----------------'
echo
"pramas:"
$1
command
=
$(
cat
updowncommand.txt
)
echo
'command:'
$command
if
[
-z
"
$1
"
]
;
then
command
=
'up
'
echo
'command reset value:'
$command
command
=
'start
'
echo
'command reset value:'
$command
fi
echo
'---------------kill.jar----------------'
KILL_PROCESS_NAME
=
'${deployPath}/${deployJar}'
PROCESS_ID
=
`
ps
-ef
|
grep
$KILL_PROCESS_NAME
|
grep
-v
'grep'
|
awk
'{print $2}'
`
...
...
@@ -19,21 +18,19 @@ echo 'ProcessId: ' $PROCESS_ID
for
id
in
$PROCESS_ID
do
echo
'KILL_ID: '
$id
kill
-s
9
$id
echo
'KILL_ID: '
$id
kill
-s
9
$id
done
echo
'---------------killed.jar----------------'
if
[
"
$command
"
!=
"down"
]
;
then
echo
'---------------start.jar----------------'
echo
'---------------killed_stop----------------'
if
[
"
$command
"
!=
"stop"
]
;
then
echo
'---------------start----------------'
nohup
/usr/local/java/jdk1.8/bin/java
-javaagent
:/usr/local/skywalking/agent/skywalking-agent.jar
-Dskywalking
.trace.ignore_path
=
/api/v1/rest/event/longpolling
-Dskywalking
.agent.service_name
=
${
serviceName
}
-Dskywalking
.collector.backend_service
=
10.0.120.212:11800,10.0.120.143:11800,10.0.120.44:11800
-Xms2g
-Xmx2g
-jar
$KILL_PROCESS_NAME
--spring
.profiles.active
=
prod
${
port
}
>
/dev/null 2>&1 &
echo
'---------------started.jar----------------'
nohup
/usr/local/java/jdk1.8/bin/java
-javaagent
:/usr/local/skywalking/agent/skywalking-agent.jar
-Dskywalking
.trace.ignore_path
=
/api/v1/rest/event/longpolling
-Dskywalking
.agent.service_name
=
loit-
${
serviceName
}
-Dskywalking
.collector.backend_service
=
10.0.120.212:11800,10.0.120.143:11800,10.0.120.44:11800
-Xms2g
-Xmx2g
-jar
$KILL_PROCESS_NAME
--spring
.profiles.active
=
${
springProfilesActive
}
>
/dev/null 2>&1 &
echo
'---------------started----------------'
fi
for
i
in
{
1..30
}
;
do
sleep
1
tail
-n5
${
deployPath
}
/logs/
${
serviceName
}
.log
sleep
1
tail
-n5
${
deployPath
}
/logs/loit-
${
serviceName
}
.log
done
fi
loit-build-component/loit-build-deploy-env/src/main/resources/template/deploy-web-sh.ftl
0 → 100644
浏览文件 @
185f74e2
#!/bin/sh
command
=
$(
cat
updowncommand.txt
)
echo
'command:'
$command
if
[
-z
"
$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
[
"
$command
"
!=
"stop"
]
;
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
}
/
#nohup ./node_modules/http-server/bin/http-server -p ${port} >/dev/null 2>&1 &
exit
fi
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论