feat: mail send failed use WARN log level

This commit is contained in:
KFCFans 2020-11-21 17:01:42 +08:00
parent 5a50d933a8
commit 1868d9289f
4 changed files with 12 additions and 38 deletions

View File

@ -50,7 +50,7 @@ public class MailAlarmService implements Alarmable {
javaMailSender.send(sm); javaMailSender.send(sm);
}catch (Exception e) { }catch (Exception e) {
log.error("[MailAlarmService] send mail failed, reason is {}", e.getMessage()); log.warn("[MailAlarmService] send mail failed, reason is {}", e.getMessage());
} }
} }

View File

@ -8,7 +8,6 @@ import com.github.kfcfans.powerjob.common.utils.NetUtils;
import com.github.kfcfans.powerjob.server.akka.OhMyServer; import com.github.kfcfans.powerjob.server.akka.OhMyServer;
import com.github.kfcfans.powerjob.server.persistence.core.model.AppInfoDO; import com.github.kfcfans.powerjob.server.persistence.core.model.AppInfoDO;
import com.github.kfcfans.powerjob.server.persistence.core.repository.AppInfoRepository; import com.github.kfcfans.powerjob.server.persistence.core.repository.AppInfoRepository;
import com.github.kfcfans.powerjob.server.persistence.core.repository.JobInfoRepository;
import com.github.kfcfans.powerjob.server.service.ha.ServerSelectService; import com.github.kfcfans.powerjob.server.service.ha.ServerSelectService;
import com.github.kfcfans.powerjob.server.service.ha.WorkerManagerService; import com.github.kfcfans.powerjob.server.service.ha.WorkerManagerService;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -35,8 +34,6 @@ public class ServerController {
private ServerSelectService serverSelectService; private ServerSelectService serverSelectService;
@Resource @Resource
private AppInfoRepository appInfoRepository; private AppInfoRepository appInfoRepository;
@Resource
private JobInfoRepository jobInfoRepository;
@GetMapping("/assert") @GetMapping("/assert")
public ResultDTO<Long> assertAppName(String appName) { public ResultDTO<Long> assertAppName(String appName) {

View File

@ -1,6 +1,7 @@
package com.github.kfcfans.powerjob.worker.autoconfigure; package com.github.kfcfans.powerjob.worker.autoconfigure;
import com.github.kfcfans.powerjob.common.utils.CommonUtils; import com.github.kfcfans.powerjob.common.utils.CommonUtils;
import com.github.kfcfans.powerjob.common.utils.NetUtils;
import com.github.kfcfans.powerjob.worker.OhMyWorker; import com.github.kfcfans.powerjob.worker.OhMyWorker;
import com.github.kfcfans.powerjob.worker.common.OhMyConfig; import com.github.kfcfans.powerjob.worker.common.OhMyConfig;
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
@ -37,8 +38,14 @@ public class PowerJobAutoConfiguration {
// 1. 创建配置文件 // 1. 创建配置文件
OhMyConfig config = new OhMyConfig(); OhMyConfig config = new OhMyConfig();
// 可以不显式设置默认值 27777
config.setPort(worker.getAkkaPort()); // 端口配置支持随机端口
int port = worker.getAkkaPort();
if (port <= 0) {
port = NetUtils.getRandomPort();
}
config.setPort(port);
// appName需要提前在控制台注册否则启动报错 // appName需要提前在控制台注册否则启动报错
config.setAppName(worker.getAppName()); config.setAppName(worker.getAppName());
config.setServerAddress(serverAddress); config.setServerAddress(serverAddress);

View File

@ -1,10 +1,10 @@
package com.github.kfcfans.powerjob.worker.common; package com.github.kfcfans.powerjob.worker.common;
import com.github.kfcfans.powerjob.common.RemoteConstant; import com.github.kfcfans.powerjob.common.RemoteConstant;
import com.github.kfcfans.powerjob.common.utils.NetUtils;
import com.github.kfcfans.powerjob.worker.common.constants.StoreStrategy; import com.github.kfcfans.powerjob.worker.common.constants.StoreStrategy;
import com.github.kfcfans.powerjob.worker.core.processor.ProcessResult; import com.github.kfcfans.powerjob.worker.core.processor.ProcessResult;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List; import java.util.List;
@ -15,6 +15,7 @@ import java.util.List;
* @author tjq * @author tjq
* @since 2020/3/16 * @since 2020/3/16
*/ */
@Getter
@Setter @Setter
public class OhMyConfig { public class OhMyConfig {
/** /**
@ -48,35 +49,4 @@ public class OhMyConfig {
* true -> 用于本地写单元测试调试 false -> 默认值标准模式 * true -> 用于本地写单元测试调试 false -> 默认值标准模式
*/ */
private boolean enableTestMode = false; private boolean enableTestMode = false;
public String getAppName() {
return appName;
}
public int getPort() {
if (port > 0) {
return port;
}
return NetUtils.getRandomPort();
}
public List<String> getServerAddress() {
return serverAddress;
}
public StoreStrategy getStoreStrategy() {
return storeStrategy;
}
public int getMaxResultLength() {
return maxResultLength;
}
public Object getUserContext() {
return userContext;
}
public boolean isEnableTestMode() {
return enableTestMode;
}
} }