feat(dashboard): 调整日志路径并优化Nacos配置
- 修改日志文件存储路径为相对路径 ./logs/csp/sentinel-dashboard.log - 默认启用认证登录功能,注释掉 auth.enabled=false 配置 - 更新 Nacos 配置,将默认地址指向本地并新增 groupId 配置项 - 动态读取 groupId 并注入到 NacosConfigUtil 中 - FlowControllerV2 使用新的 FlowRuleApiProvider 和 FlowRuleApiPublisher 替代原有实现 - 注释旧的动态规则提供器和发布器引用
This commit is contained in:
parent
b14de1ea5f
commit
ff999c6703
|
|
@ -21,6 +21,8 @@ import java.util.List;
|
|||
import com.alibaba.csp.sentinel.dashboard.auth.AuthAction;
|
||||
import com.alibaba.csp.sentinel.dashboard.auth.AuthService;
|
||||
import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType;
|
||||
import com.alibaba.csp.sentinel.dashboard.rule.apiProvider.FlowRuleApiProvider;
|
||||
import com.alibaba.csp.sentinel.dashboard.rule.apiPublisher.FlowRuleApiPublisher;
|
||||
import com.alibaba.csp.sentinel.util.StringUtil;
|
||||
|
||||
import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity;
|
||||
|
|
@ -58,12 +60,19 @@ public class FlowControllerV2 {
|
|||
@Autowired
|
||||
private InMemoryRuleRepositoryAdapter<FlowRuleEntity> repository;
|
||||
|
||||
// @Autowired
|
||||
// @Qualifier("flowRuleDefaultProvider")
|
||||
// private DynamicRuleProvider<List<FlowRuleEntity>> ruleProvider;
|
||||
//
|
||||
// @Autowired
|
||||
// @Qualifier("flowRuleDefaultPublisher")
|
||||
// private DynamicRulePublisher<List<FlowRuleEntity>> rulePublisher;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("flowRuleDefaultProvider")
|
||||
private DynamicRuleProvider<List<FlowRuleEntity>> ruleProvider;
|
||||
private FlowRuleApiProvider ruleProvider;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("flowRuleDefaultPublisher")
|
||||
private DynamicRulePublisher<List<FlowRuleEntity>> rulePublisher;
|
||||
private FlowRuleApiPublisher rulePublisher;
|
||||
|
||||
@GetMapping("/rules")
|
||||
@AuthAction(PrivilegeType.READ_RULE)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package com.alibaba.csp.sentinel.dashboard.rule.nacos;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @author Ms.He
|
||||
* 2025-11-21 07:37
|
||||
|
|
@ -23,8 +25,7 @@ package com.alibaba.csp.sentinel.dashboard.rule.nacos;
|
|||
* pc-name mshe
|
||||
*/
|
||||
public final class NacosConfigUtil {
|
||||
|
||||
public static final String GROUP_ID = "DEFAULT_GROUP";
|
||||
public static String GROUP_ID = "DEFAULT_GROUP";
|
||||
public static final String GLOBAL_DATA_ID_POSTFIX = ".json";
|
||||
|
||||
// 流控规则
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "nacos.config")
|
||||
public class NacosServerConfig {
|
||||
|
|
@ -11,6 +13,12 @@ public class NacosServerConfig {
|
|||
private String namespace;
|
||||
private String username;
|
||||
private String password;
|
||||
private String groupId;
|
||||
|
||||
@PostConstruct
|
||||
public void doInit() {
|
||||
NacosConfigUtil.GROUP_ID = groupId;
|
||||
}
|
||||
|
||||
public String getServerAddr() {
|
||||
return serverAddr;
|
||||
|
|
@ -44,6 +52,14 @@ public class NacosServerConfig {
|
|||
this.password = password;
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JSONObject.toJSONString(this);
|
||||
|
|
|
|||
|
|
@ -6,13 +6,14 @@ server.servlet.encoding.enabled=true
|
|||
server.servlet.session.cookie.name=sentinel_dashboard_cookie
|
||||
#logging settings
|
||||
logging.level.org.springframework.web=INFO
|
||||
logging.file.name=${user.home}/logs/csp/sentinel-dashboard.log
|
||||
logging.file.name=./logs/csp/sentinel-dashboard.log
|
||||
logging.pattern.file=%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
|
||||
#logging.pattern.console= %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
|
||||
#auth settings
|
||||
auth.filter.exclude-urls=/,/auth/login,/auth/logout,/registry/machine,/version
|
||||
auth.filter.exclude-url-suffixes=htm,html,js,css,map,ico,ttf,woff,png
|
||||
# If auth.enabled=false, Sentinel console disable login
|
||||
#auth.enabled=false
|
||||
auth.username=admin
|
||||
auth.password=admin
|
||||
# Inject the dashboard version. It's required to enable
|
||||
|
|
@ -20,9 +21,10 @@ auth.password=admin
|
|||
sentinel.dashboard.version=@project.version@
|
||||
##############################################################
|
||||
# nacos config
|
||||
#nacos.config.server-addr=http://127.0.0.1:8848
|
||||
nacos.config.server-addr=http://172.16.8.70:8848
|
||||
nacos.config.server-addr=http://127.0.0.1:8848
|
||||
#nacos.config.server-addr=http://172.16.8.70:8848
|
||||
nacos.config.namespace=namespace-sentinel
|
||||
nacos.config.groupId=DEFAULT_GROUP
|
||||
nacos.config.username=
|
||||
nacos.config.password=
|
||||
##############################################################
|
||||
|
|
|
|||
Loading…
Reference in New Issue