设置只启用初始服务
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import cc.winboll.LogUtils;
|
||||
import cc.winboll.WinBoLL;
|
||||
import cc.winboll.test.ConsoleCmdAutoTest;
|
||||
import cc.winboll.util.IniConfigUtils;
|
||||
import java.util.Date;
|
||||
@@ -48,6 +49,7 @@ public class Main {
|
||||
ConsoleCmdAutoTest.main(args);
|
||||
|
||||
LogUtils.i("Main", "正在处理事务...");
|
||||
WinBoLL.main(args);
|
||||
|
||||
|
||||
} finally {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class WinBoLL {
|
||||
MainUtils.setExit(false);
|
||||
|
||||
// 解析启动参数 + 加载INI根配置
|
||||
MainUtils.parseArgs(args);
|
||||
/*MainUtils.parseArgs(args);
|
||||
LogUtils.d(TAG, "【参数信息】main(),传入启动参数:" + MainUtils.arrayToString(args));
|
||||
|
||||
|
||||
@@ -54,30 +54,32 @@ public class WinBoLL {
|
||||
|
||||
// 获取解析后各项参数
|
||||
boolean showDetailEnv = MainUtils.parseDetailArg();
|
||||
*/
|
||||
|
||||
String serverUrl = MainUtils.getFinalServerUrl();
|
||||
httpPort = MainUtils.getHttpPortFromConfig();
|
||||
LogUtils.d(TAG, "【参数信息】main(),解析后服务器地址:" + serverUrl + ",服务端口:" + httpPort);
|
||||
|
||||
// 环境信息打印 + 工具类初始化
|
||||
EnvInfoUtils.printEnvReport(showDetailEnv);
|
||||
initServerUtils(serverUrl);
|
||||
// 调整:邮件工具单例初始化,增加结果判断+日志输出
|
||||
initEmailSendUtils();
|
||||
|
||||
// 启动配置校验
|
||||
boolean initCheckPass = InitCheckUtils.checkAllInitConfig();
|
||||
if (!initCheckPass) {
|
||||
LogUtils.e(TAG, "初始化校验未通过,程序退出");
|
||||
MainUtils.setExit(true);
|
||||
System.exit(1);
|
||||
}
|
||||
// // 环境信息打印 + 工具类初始化
|
||||
// EnvInfoUtils.printEnvReport(showDetailEnv);
|
||||
// initServerUtils(serverUrl);
|
||||
// // 调整:邮件工具单例初始化,增加结果判断+日志输出
|
||||
// initEmailSendUtils();
|
||||
//
|
||||
// // 启动配置校验
|
||||
// boolean initCheckPass = InitCheckUtils.checkAllInitConfig();
|
||||
// if (!initCheckPass) {
|
||||
// LogUtils.e(TAG, "初始化校验未通过,程序退出");
|
||||
// MainUtils.setExit(true);
|
||||
// System.exit(1);
|
||||
// }
|
||||
|
||||
System.out.println("Hello World!");
|
||||
|
||||
// 启动HTTP服务 + 初始化控制台
|
||||
startAuthCenterHttpService();
|
||||
ConsoleInputUtils.initConsoleScanner();
|
||||
AdminUtils.getInstance().sendServiceStartNotify();
|
||||
//AdminUtils.getInstance().sendServiceStartNotify();
|
||||
LogUtils.i(TAG, "HTTP服务+控制台初始化完成,服务进入常驻状态");
|
||||
|
||||
// 控制台阻塞监听
|
||||
@@ -86,8 +88,8 @@ public class WinBoLL {
|
||||
// 正常退出 释放资源
|
||||
LogUtils.d(TAG, "【函数执行】main(),开始执行资源释放与停机流程");
|
||||
ConsoleInputUtils.closeConsoleScanner();
|
||||
AdminUtils.getInstance().sendServiceStopNotify();
|
||||
MainUtils.releaseAllResources(httpService);
|
||||
//AdminUtils.getInstance().sendServiceStopNotify();
|
||||
//MainUtils.releaseAllResources(httpService);
|
||||
LogUtils.i(TAG, "【函数结束】main(),AuthCenter程序正常退出");
|
||||
}
|
||||
|
||||
|
||||
@@ -47,33 +47,44 @@ public class AuthCenterHttpService extends NanoHTTPD {
|
||||
|
||||
try {
|
||||
// 分发请求到对应处理方法
|
||||
if (Method.GET.equals(method) && "/authcenter/ping".equals(normUri)) {
|
||||
return handlePingRequest();
|
||||
} else if (Method.POST.equals(method) && "/api/sendVerifyCode".equals(normUri)) {
|
||||
return handleSendVerifyCode(session);
|
||||
} else if (Method.POST.equals(method) && "/api/verifyCode".equals(normUri)) {
|
||||
return handleVerifyCode(session);
|
||||
} else if (Method.POST.equals(method) && "/api/submitPublicKey".equals(normUri)) {
|
||||
return handleSubmitPublicKey(session);
|
||||
} else if (Method.POST.equals(method) && "/api/heartbeat/ping".equals(normUri)) {
|
||||
return handleHeartbeatPing(session);
|
||||
// if (Method.GET.equals(method) && "/authcenter/ping".equals(normUri)) {
|
||||
// return handlePingRequest();
|
||||
// } else if (Method.POST.equals(method) && "/api/sendVerifyCode".equals(normUri)) {
|
||||
// return handleSendVerifyCode(session);
|
||||
// } else if (Method.POST.equals(method) && "/api/verifyCode".equals(normUri)) {
|
||||
// return handleVerifyCode(session);
|
||||
// } else if (Method.POST.equals(method) && "/api/submitPublicKey".equals(normUri)) {
|
||||
// return handleSubmitPublicKey(session);
|
||||
// } else if (Method.POST.equals(method) && "/api/heartbeat/ping".equals(normUri)) {
|
||||
// return handleHeartbeatPing(session);
|
||||
// }
|
||||
if (Method.GET.equals(method) && "/".equals(normUri)) {
|
||||
return handleHelloWorld();
|
||||
} else {
|
||||
LogUtils.d(TAG, "非目标请求,返回404");
|
||||
return newFixedLengthResponse(Response.Status.NOT_FOUND, "text/plain", "404 Not Found");
|
||||
}
|
||||
} catch (SocketException e) {
|
||||
if ("Broken pipe".equals(e.getMessage())) {
|
||||
LogUtils.d(TAG, "客户端提前断开连接,忽略异常");
|
||||
} else {
|
||||
LogUtils.e(TAG, "请求处理时Socket异常", e);
|
||||
}
|
||||
return newFixedLengthResponse(Response.Status.BAD_REQUEST, "text/plain", "Client disconnected");
|
||||
// } catch (SocketException e) {
|
||||
// if ("Broken pipe".equals(e.getMessage())) {
|
||||
// LogUtils.d(TAG, "客户端提前断开连接,忽略异常");
|
||||
// } else {
|
||||
// LogUtils.e(TAG, "请求处理时Socket异常", e);
|
||||
// }
|
||||
// return newFixedLengthResponse(Response.Status.BAD_REQUEST, "text/plain", "Client disconnected");
|
||||
} catch (Exception e) {
|
||||
LogUtils.e(TAG, "请求处理异常", e);
|
||||
return newFixedLengthResponse(Response.Status.INTERNAL_ERROR, "application/json",
|
||||
"{\"code\":500,\"msg\":\"服务内部异常\",\"data\":null}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理根路径默认请求
|
||||
*/
|
||||
private Response handleHelloWorld() {
|
||||
LogUtils.d(TAG, "根路径请求响应成功,返回服务运行标识");
|
||||
return newFixedLengthResponse(Response.Status.OK, "text/plain", "WinBoLL is Running...");
|
||||
}
|
||||
|
||||
// 处理ping请求
|
||||
private Response handlePingRequest() {
|
||||
|
||||
Reference in New Issue
Block a user