Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
fe77f081
Commit
fe77f081
authored
May 08, 2020
by
zhanghouying
Committed by
ZhengJie
May 08, 2020
Browse files
[Bug修复](v2.5): v2.5 beta 解决部署到linux服务器路径拼接不正确问题
Closes #347
parent
6c4e226a
Changes
4
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DatabaseController.java
View file @
fe77f081
...
...
@@ -49,7 +49,7 @@ import java.util.Set;
@RequestMapping
(
"/api/database"
)
public
class
DatabaseController
{
private
final
String
fileSavePath
=
System
.
getProperty
(
"java.io.tmpdir"
)
;
private
final
String
fileSavePath
=
FileUtil
.
getTmpDirPath
()+
"/"
;
private
final
DatabaseService
databaseService
;
@Log
(
"导出数据库数据"
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DeployController.java
View file @
fe77f081
...
...
@@ -50,7 +50,7 @@ import java.util.Set;
@RequestMapping
(
"/api/deploy"
)
public
class
DeployController
{
private
final
String
fileSavePath
=
System
.
getProperty
(
"java.io.tmpdir"
)
;
private
final
String
fileSavePath
=
FileUtil
.
getTmpDirPath
()+
"/"
;
private
final
DeployService
deployService
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java
View file @
fe77f081
...
...
@@ -28,7 +28,10 @@ import me.zhengjie.modules.mnt.repository.DeployRepository;
import
me.zhengjie.modules.mnt.service.DeployHistoryService
;
import
me.zhengjie.modules.mnt.service.DeployService
;
import
me.zhengjie.modules.mnt.service.ServerDeployService
;
import
me.zhengjie.modules.mnt.service.dto.*
;
import
me.zhengjie.modules.mnt.service.dto.AppDto
;
import
me.zhengjie.modules.mnt.service.dto.DeployDto
;
import
me.zhengjie.modules.mnt.service.dto.DeployQueryCriteria
;
import
me.zhengjie.modules.mnt.service.dto.ServerDeployDto
;
import
me.zhengjie.modules.mnt.service.mapstruct.DeployMapper
;
import
me.zhengjie.modules.mnt.util.ExecuteShellUtil
;
import
me.zhengjie.modules.mnt.util.ScpClientUtil
;
...
...
@@ -41,6 +44,7 @@ import org.springframework.data.domain.Pageable;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.*
;
...
...
@@ -155,7 +159,7 @@ public class DeployServiceImpl implements DeployService {
stopApp
(
port
,
executeShellUtil
);
sendMsg
(
"备份原来应用"
,
MsgType
.
INFO
);
//备份应用
backupApp
(
executeShellUtil
,
ip
,
app
.
getDeployPath
(),
app
.
getName
(),
app
.
getBackupPath
(),
id
);
backupApp
(
executeShellUtil
,
ip
,
app
.
getDeployPath
()
+
FILE_SEPARATOR
,
app
.
getName
(),
app
.
getBackupPath
()
+
FILE_SEPARATOR
,
id
);
}
sendMsg
(
"部署应用"
,
MsgType
.
INFO
);
//部署文件,并启动应用
...
...
@@ -191,16 +195,9 @@ public class DeployServiceImpl implements DeployService {
private
void
backupApp
(
ExecuteShellUtil
executeShellUtil
,
String
ip
,
String
fileSavePath
,
String
appName
,
String
backupPath
,
Long
id
)
{
String
deployDate
=
DateUtil
.
format
(
new
Date
(),
DatePattern
.
PURE_DATETIME_PATTERN
);
StringBuilder
sb
=
new
StringBuilder
();
String
endsWith
=
"\\"
;
if
(!
backupPath
.
endsWith
(
FILE_SEPARATOR
)&&!
backupPath
.
endsWith
(
endsWith
))
{
backupPath
+=
FILE_SEPARATOR
;
}
backupPath
+=
appName
+
FILE_SEPARATOR
+
deployDate
+
"\n"
;
sb
.
append
(
"mkdir -p "
).
append
(
backupPath
);
sb
.
append
(
"mv -f "
).
append
(
fileSavePath
);
if
(!
fileSavePath
.
endsWith
(
FILE_SEPARATOR
))
{
sb
.
append
(
FILE_SEPARATOR
);
}
sb
.
append
(
appName
).
append
(
" "
).
append
(
backupPath
);
log
.
info
(
"备份应用脚本:"
+
sb
.
toString
());
executeShellUtil
.
execute
(
sb
.
toString
());
...
...
@@ -350,10 +347,7 @@ public class DeployServiceImpl implements DeployService {
sendMsg
(
"应用信息不存在:"
+
resources
.
getAppName
(),
MsgType
.
ERROR
);
throw
new
BadRequestException
(
"应用信息不存在:"
+
resources
.
getAppName
());
}
String
backupPath
=
app
.
getBackupPath
();
if
(!
backupPath
.
endsWith
(
FILE_SEPARATOR
))
{
backupPath
+=
FILE_SEPARATOR
;
}
String
backupPath
=
app
.
getBackupPath
()+
FILE_SEPARATOR
;
backupPath
+=
resources
.
getAppName
()
+
FILE_SEPARATOR
+
deployDate
;
//这个是服务器部署路径
String
deployPath
=
app
.
getDeployPath
();
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ScpClientUtil.java
View file @
fe77f081
...
...
@@ -31,18 +31,18 @@ public class ScpClientUtil {
static
private
ScpClientUtil
instance
;
static
synchronized
public
ScpClientUtil
getInstance
(
String
ip
,
int
port
,
String
username
,
String
passw
a
rd
)
{
static
synchronized
public
ScpClientUtil
getInstance
(
String
ip
,
int
port
,
String
username
,
String
passw
o
rd
)
{
if
(
instance
==
null
)
{
instance
=
new
ScpClientUtil
(
ip
,
port
,
username
,
passw
a
rd
);
instance
=
new
ScpClientUtil
(
ip
,
port
,
username
,
passw
o
rd
);
}
return
instance
;
}
public
ScpClientUtil
(
String
ip
,
int
port
,
String
username
,
String
passw
a
rd
)
{
public
ScpClientUtil
(
String
ip
,
int
port
,
String
username
,
String
passw
o
rd
)
{
this
.
ip
=
ip
;
this
.
port
=
port
;
this
.
username
=
username
;
this
.
password
=
passw
a
rd
;
this
.
password
=
passw
o
rd
;
}
public
void
getFile
(
String
remoteFile
,
String
localTargetDirectory
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment