Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_42566577
o2oa
提交
b5859d70
o2oa
项目概览
weixin_42566577
/
o2oa
与 Fork 源项目一致
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b5859d70
编写于
11月 22, 2021
作者:
O
o2null
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修正windows下中文路径无法启动的问题
上级
e25fe8ee
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
110 addition
and
54 deletion
+110
-54
o2server/x_base_core_project/src/main/java/com/x/base/core/project/build/CreateConfigSample.java
...ava/com/x/base/core/project/build/CreateConfigSample.java
+1
-1
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/BaseTools.java
...rc/main/java/com/x/base/core/project/tools/BaseTools.java
+72
-37
o2server/x_console/src/main/java/com/x/server/console/Main.java
...er/x_console/src/main/java/com/x/server/console/Main.java
+37
-16
未找到文件。
o2server/x_base_core_project/src/main/java/com/x/base/core/project/build/CreateConfigSample.java
浏览文件 @
b5859d70
...
...
@@ -116,7 +116,7 @@ public class CreateConfigSample {
String
name
=
StringUtils
.
lowerCase
(
cls
.
getSimpleName
().
substring
(
0
,
1
))
+
cls
.
getSimpleName
().
substring
(
1
)
+
".json"
;
File
file
=
new
File
(
dir
.
toFile
(),
name
);
logger
.
print
(
"create file:{}."
,
file
.
getAbsoluteFile
());
//
logger.print("create file:{}.", file.getAbsoluteFile());
FileUtils
.
write
(
file
,
XGsonBuilder
.
toJson
(
map
),
DefaultCharset
.
charset
);
}
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/BaseTools.java
浏览文件 @
b5859d70
package
com.x.base.core.project.tools
;
import
java.io.*
;
import
java.io.DataInputStream
;
import
java.io.DataOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.Inet4Address
;
import
java.net.InetAddress
;
import
java.net.NetworkInterface
;
import
java.net.Socket
;
import
java.util.*
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.ArrayList
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Objects
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.config.ConfigObject
;
import
com.x.base.core.project.config.Nodes
;
import
com.x.base.core.project.gson.XGsonBuilder
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.config.Nodes
;
import
com.x.base.core.project.gson.XGsonBuilder
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
public
class
BaseTools
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
BaseTools
.
class
);
public
static
String
getBasePath
()
throws
Exception
{
return
getBaseDirectory
().
getAbsolutePath
();
public
static
String
getBasePath
()
throws
IOException
,
URISyntaxException
{
return
getBaseDirectory
().
toAbsolutePath
().
toString
();
}
public
static
File
getBaseDirectory
()
throws
Exception
{
String
path
=
BaseTools
.
class
.
getProtectionDomain
().
getCodeSource
().
getLocation
().
getPath
();
File
file
=
new
File
(
path
);
if
(!
file
.
isDirectory
())
{
file
=
file
.
getParentFile
();
}
while
(
null
!=
file
)
{
File
versionFile
=
new
File
(
file
,
"version.o2"
);
if
(
versionFile
.
exists
())
{
return
file
;
/**
* 从Main.class所在的目录开始递归向上,找到version.o2所在目录,就是程序根目录.
*
* @return
* @throws IOException
* @throws URISyntaxException
*/
private
static
Path
getBaseDirectory
()
throws
IOException
,
URISyntaxException
{
Path
path
=
Paths
.
get
(
new
URI
(
"file://"
+
BaseTools
.
class
.
getProtectionDomain
().
getCodeSource
().
getLocation
().
getPath
()));
while
(
Files
.
exists
(
path
))
{
Path
versionFile
=
path
.
resolve
(
"version.o2"
);
if
(
Files
.
exists
(
versionFile
)
&&
Files
.
isRegularFile
(
versionFile
))
{
return
path
.
toAbsolutePath
();
}
file
=
file
.
getParentFile
();
path
=
path
.
getParent
();
}
throw
new
Exception
(
"can not define o2server base directory."
);
throw
new
IO
Exception
(
"can not define o2server base directory."
);
}
// public static File getBaseDirectory() throws Exception {
// String path = BaseTools.class.getProtectionDomain().getCodeSource().getLocation().getPath();
// File file = new File(path);
// if (!file.isDirectory()) {
// file = file.getParentFile();
// }
// while (null != file) {
// File versionFile = new File(file, "version.o2");
// if (versionFile.exists()) {
// return file;
// }
// file = file.getParentFile();
// }
// throw new Exception("can not define o2server base directory.");
// }
public
static
<
T
>
T
readConfigObject
(
String
path
,
Class
<
T
>
cls
)
throws
Exception
{
String
base
=
BaseTools
.
getBasePath
();
File
file
=
new
File
(
base
,
path
);
...
...
@@ -136,28 +172,28 @@ public class BaseTools {
String
base
=
BaseTools
.
getBasePath
();
File
file
=
new
File
(
base
,
path
);
if
((!
file
.
exists
())
||
file
.
isDirectory
())
{
//throw new Exception("can not get file with path:" + file.getAbsolutePath());
//
throw new Exception("can not get file with path:" + file.getAbsolutePath());
return
null
;
}
return
FileUtils
.
readFileToString
(
file
,
DefaultCharset
.
charset
);
}
public
static
boolean
executeSyncFile
(
String
syncFilePath
)
throws
Exception
{
public
static
boolean
executeSyncFile
(
String
syncFilePath
)
throws
Exception
{
boolean
Syncflag
=
false
;
Nodes
nodes
=
Config
.
nodes
();
//同步config文件
if
(
Config
.
nodes
().
centerServers
().
first
().
getValue
().
getConfigApiEnable
())
{
//
同步config文件
if
(
Config
.
nodes
().
centerServers
().
first
().
getValue
().
getConfigApiEnable
())
{
for
(
String
node
:
nodes
.
keySet
())
{
if
(
nodes
.
get
(
node
).
getApplication
().
getEnable
()
||
nodes
.
get
(
node
).
getCenter
().
getEnable
())
{
Syncflag
=
executeSyncFile
(
syncFilePath
,
node
,
nodes
.
get
(
node
).
nodeAgentPort
());
}
}
}
return
Syncflag
;
return
Syncflag
;
}
private
static
boolean
executeSyncFile
(
String
syncFilePath
,
String
nodeName
,
int
nodePort
)
{
private
static
boolean
executeSyncFile
(
String
syncFilePath
,
String
nodeName
,
int
nodePort
)
{
boolean
syncFileFlag
=
false
;
File
syncFile
;
InputStream
fileInputStream
=
null
;
...
...
@@ -165,18 +201,18 @@ public class BaseTools {
try
(
Socket
socket
=
new
Socket
(
nodeName
,
nodePort
))
{
syncFile
=
new
File
(
Config
.
base
(),
syncFilePath
);
fileInputStream
=
new
FileInputStream
(
syncFile
);
fileInputStream
=
new
FileInputStream
(
syncFile
);
socket
.
setKeepAlive
(
true
);
socket
.
setSoTimeout
(
2000
);
DataOutputStream
dos
=
null
;
DataInputStream
dis
=
null
;
DataInputStream
dis
=
null
;
try
{
dos
=
new
DataOutputStream
(
socket
.
getOutputStream
());
dis
=
new
DataInputStream
(
socket
.
getInputStream
());
Map
<
String
,
Object
>
commandObject
=
new
HashMap
<>();
commandObject
.
put
(
"command"
,
"syncFile:"
+
syncFilePath
);
commandObject
.
put
(
"command"
,
"syncFile:"
+
syncFilePath
);
commandObject
.
put
(
"credential"
,
Crypto
.
rsaEncrypt
(
"o2@"
,
Config
.
publicKey
()));
dos
.
writeUTF
(
XGsonBuilder
.
toJson
(
commandObject
));
dos
.
flush
();
...
...
@@ -184,17 +220,16 @@ public class BaseTools {
dos
.
writeUTF
(
syncFilePath
);
dos
.
flush
();
logger
.
info
(
"同步文件:"
+
syncFilePath
+
" starting..."
);
logger
.
info
(
"同步文件:"
+
syncFilePath
+
" starting..."
);
byte
[]
bytes
=
new
byte
[
1024
];
int
length
=
0
;
while
((
length
=
fileInputStream
.
read
(
bytes
,
0
,
bytes
.
length
))
!=
-
1
)
{
int
length
=
0
;
while
((
length
=
fileInputStream
.
read
(
bytes
,
0
,
bytes
.
length
))
!=
-
1
)
{
dos
.
write
(
bytes
,
0
,
length
);
dos
.
flush
();
}
logger
.
info
(
"同步文件:"
+
syncFilePath
+
"end."
);
logger
.
info
(
"同步文件:"
+
syncFilePath
+
"end."
);
}
finally
{
}
finally
{
dos
.
close
();
dis
.
close
();
socket
.
close
();
...
...
o2server/x_console/src/main/java/com/x/server/console/Main.java
浏览文件 @
b5859d70
...
...
@@ -12,6 +12,8 @@ import java.lang.management.ManagementFactory;
import
java.lang.management.RuntimeMXBean
;
import
java.lang.reflect.Method
;
import
java.net.Socket
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.net.URL
;
import
java.net.URLClassLoader
;
import
java.nio.MappedByteBuffer
;
...
...
@@ -111,7 +113,7 @@ public class Main {
},
"consoleCommandThread"
);
private
static
void
init
()
throws
Exception
{
String
base
=
getBasePath
();
String
base
=
getBasePath
()
.
toString
()
;
pid
(
base
);
scanWar
(
base
);
cleanTempDir
(
base
);
...
...
@@ -675,26 +677,45 @@ public class Main {
method
.
invoke
(
urlClassLoader
,
new
Object
[]
{
local_temp_classes_dir
.
toURI
().
toURL
()
});
}
private
static
String
getBasePath
()
throws
Exception
{
String
path
=
Main
.
class
.
getProtectionDomain
().
getCodeSource
().
getLocation
().
getPath
();
File
file
=
new
File
(
path
);
if
(!
file
.
isDirectory
())
{
file
=
file
.
getParentFile
();
}
while
(
null
!=
file
)
{
File
versionFile
=
new
File
(
file
,
"version.o2"
);
if
(
versionFile
.
exists
())
{
return
file
.
getAbsolutePath
();
/**
* 从Main.class所在的目录开始递归向上,找到version.o2所在目录,就是程序根目录.
*
* @return
* @throws IOException
* @throws URISyntaxException
*/
private
static
Path
getBasePath
()
throws
IOException
,
URISyntaxException
{
Path
path
=
Paths
.
get
(
new
URI
(
"file://"
+
Main
.
class
.
getProtectionDomain
().
getCodeSource
().
getLocation
().
getPath
()));
while
(
Files
.
exists
(
path
))
{
Path
versionFile
=
path
.
resolve
(
"version.o2"
);
if
(
Files
.
exists
(
versionFile
)
&&
Files
.
isRegularFile
(
versionFile
))
{
return
path
.
toAbsolutePath
();
}
file
=
file
.
getParentFile
();
path
=
path
.
getParent
();
}
throw
new
Exception
(
"can not define o2server base directory."
);
throw
new
IO
Exception
(
"can not define o2server base directory."
);
}
// private static String getBasePath() throws Exception {
// String path = Main.class.getProtectionDomain().getCodeSource().getLocation().getPath();
// File file = new File(path);
// if (!file.isDirectory()) {
// file = file.getParentFile();
// }
// while (null != file) {
// File versionFile = new File(file, "version.o2");
// if (versionFile.exists()) {
// return file.getAbsolutePath();
// }
// file = file.getParentFile();
// }
// throw new Exception("can not define o2server base directory.");
// }
private
static
void
cleanTempDir
(
String
base
)
throws
Exception
{
File
local_temp_dir
=
new
File
(
base
,
"local/temp"
);
FileUtils
.
forceMkdir
(
local_temp_dir
);
FileUtils
.
cleanDirectory
(
local_temp_dir
);
File
temp
=
new
File
(
base
,
"local/temp"
);
FileUtils
.
forceMkdir
(
temp
);
FileUtils
.
cleanDirectory
(
temp
);
}
private
static
List
<
String
>
readManifest
(
File
file
)
throws
Exception
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录