Skip to content

Commit

Permalink
细节调整
Browse files Browse the repository at this point in the history
  • Loading branch information
jiashuaizhang committed Dec 19, 2021
1 parent 21b8f37 commit 564b364
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.concurrent.atomic.AtomicBoolean;

import static com.zhangjiashuai.yyetshistory.util.NativeOperationUtils.onStartFinish;
import static com.zhangjiashuai.yyetshistory.util.NativeOperationUtils.onStartPrepare;

Expand All @@ -14,7 +12,7 @@ public class YyetsHistoryApplication {
public static void main(String[] args) {
onStartPrepare(args);
SpringApplication.run(YyetsHistoryApplication.class, args);
onStartFinish(args);
onStartFinish();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ static boolean isStartPrepareEvent(String[] args) {
return eventCheck(key, args);
}

static boolean isStartFinishEvent(String[] args) {
static boolean isStartFinishEvent() {
String key = "yyets-history.start-finish-event";
Object configValue = getProperty(key);
if(configValue != null) {
return Boolean.parseBoolean(configValue.toString());
}
return eventCheck(key, args);
return true;
}

private static boolean eventCheck(String key, String[] args) {
Expand All @@ -157,7 +157,7 @@ private static boolean eventCheck(String key, String[] args) {
for (String arg : args) {
if(StrUtil.startWith(arg, COMMAND_LINE_ARG_PREFIX + key)) {
Pair<String, String> pair = getCommandLineArg(arg);
strValue = pair.getValue();
strValue = Optional.ofNullable(pair).map(Pair::getValue).orElse(null);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ private static void buildUri(String host, int port) {
*/
public static void onStartPrepare(String[] args) {
String classLoader = NativeOperationUtils.class.getClassLoader().getClass().getSimpleName();
log.debug("onStartPrepare, classloader {}", classLoader);
if(classLoader.endsWith("RestartClassLoader")) {
return;
}
Expand All @@ -58,15 +57,15 @@ public static void onStartPrepare(String[] args) {
NativeConfigUtil.loadCommandLineArgs(args);
String host = NativeConfigUtil.getHost();
int port = NativeConfigUtil.getPort();
buildUri(host, port);
if(!telnet(host, port)) {
return;
}
log.info("探测到项目访问路径上有服务运行");
buildUri(host, port);
Pair<String, Long> processInfo = getRunningProcessInfo();
if (APPLICATION_INFO.equals(processInfo.getKey())) {
log.info("服务已在另一进程运行,pid: {}", processInfo.getValue());
onStartFinish(args);
onStartFinish();
} else {
openErrorDialog ("端口冲突","当前地址: " + uri + " 已被占用");
}
Expand All @@ -75,10 +74,9 @@ public static void onStartPrepare(String[] args) {

/**
* 启动成功触发事件
* @param uri 项目访问地址
*/
public static void onStartFinish(String[] args) {
if(!NativeConfigUtil.isStartFinishEvent(args)) {
public static void onStartFinish() {
if(!NativeConfigUtil.isStartFinishEvent()) {
return;
}
if(uri == null) {
Expand Down
2 changes: 1 addition & 1 deletion yyets-history/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pagehelper:
server:
port: 9000
yyets-history:
link-way-filter: #保留的链接类型
link-way-filter: # 保留的链接类型
- 电驴
- 磁力
host: localhost # 域名
Expand Down

0 comments on commit 564b364

Please sign in to comment.