mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-03 23:20:26 +08:00
集群设置中增加“自动调节系统参数”选项
This commit is contained in:
@@ -12,5 +12,5 @@ dbs:
|
||||
|
||||
|
||||
fields:
|
||||
bool: [ "uamIsOn", "followPort", "requestHostExcludingPort", "autoRemoteStart", "autoInstallNftables", "enableIPLists", "detectAgents", "checkingPorts", "enableRecordHealthCheck", "offlineIsNotified", "http2Enabled", "http3Enabled", "enableHTTP2", "retry50X" ]
|
||||
bool: [ "uamIsOn", "followPort", "requestHostExcludingPort", "autoRemoteStart", "autoInstallNftables", "enableIPLists", "detectAgents", "checkingPorts", "enableRecordHealthCheck", "offlineIsNotified", "http2Enabled", "http3Enabled", "enableHTTP2", "retry50X", "autoSystemTuning" ]
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ func (this *NodeClusterDAO) FindAllEnableClusterIds(tx *dbs.Tx) (result []int64,
|
||||
}
|
||||
|
||||
// CreateCluster 创建集群
|
||||
func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string, grantId int64, installDir string, dnsDomainId int64, dnsName string, dnsTTL int32, cachePolicyId int64, httpFirewallPolicyId int64, systemServices map[string]maps.Map, globalServerConfig *serverconfigs.GlobalServerConfig, autoInstallNftables bool) (clusterId int64, err error) {
|
||||
func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string, grantId int64, installDir string, dnsDomainId int64, dnsName string, dnsTTL int32, cachePolicyId int64, httpFirewallPolicyId int64, systemServices map[string]maps.Map, globalServerConfig *serverconfigs.GlobalServerConfig, autoInstallNftables bool, autoSystemTuning bool) (clusterId int64, err error) {
|
||||
uniqueId, err := this.GenUniqueId(tx)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -189,6 +189,7 @@ func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string
|
||||
op.UniqueId = uniqueId
|
||||
op.Secret = secret
|
||||
op.AutoInstallNftables = autoInstallNftables
|
||||
op.AutoSystemTuning = autoSystemTuning
|
||||
op.State = NodeClusterStateEnabled
|
||||
err = this.Save(tx, op)
|
||||
if err != nil {
|
||||
@@ -199,7 +200,7 @@ func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string
|
||||
}
|
||||
|
||||
// UpdateCluster 修改集群
|
||||
func (this *NodeClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name string, grantId int64, installDir string, timezone string, nodeMaxThreads int32, autoOpenPorts bool, clockConfig *nodeconfigs.ClockConfig, autoRemoteStart bool, autoInstallTables bool, sshParams *nodeconfigs.SSHParams) error {
|
||||
func (this *NodeClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name string, grantId int64, installDir string, timezone string, nodeMaxThreads int32, autoOpenPorts bool, clockConfig *nodeconfigs.ClockConfig, autoRemoteStart bool, autoInstallTables bool, sshParams *nodeconfigs.SSHParams, autoSystemTuning bool) error {
|
||||
if clusterId <= 0 {
|
||||
return errors.New("invalid clusterId")
|
||||
}
|
||||
@@ -226,6 +227,7 @@ func (this *NodeClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name stri
|
||||
|
||||
op.AutoRemoteStart = autoRemoteStart
|
||||
op.AutoInstallNftables = autoInstallTables
|
||||
op.AutoSystemTuning = autoSystemTuning
|
||||
|
||||
if sshParams != nil {
|
||||
sshParamsJSON, err := json.Marshal(sshParams)
|
||||
@@ -1019,7 +1021,7 @@ func (this *NodeClusterDAO) FindClusterBasicInfo(tx *dbs.Tx, clusterId int64, ca
|
||||
cluster, err := this.Query(tx).
|
||||
Pk(clusterId).
|
||||
State(NodeClusterStateEnabled).
|
||||
Result("id", "name", "timeZone", "nodeMaxThreads", "cachePolicyId", "httpFirewallPolicyId", "autoOpenPorts", "webp", "uam", "cc", "httpPages", "http3", "isOn", "ddosProtection", "clock", "globalServerConfig", "autoInstallNftables").
|
||||
Result("id", "name", "timeZone", "nodeMaxThreads", "cachePolicyId", "httpFirewallPolicyId", "autoOpenPorts", "webp", "uam", "cc", "httpPages", "http3", "isOn", "ddosProtection", "clock", "globalServerConfig", "autoInstallNftables", "autoSystemTuning").
|
||||
Find()
|
||||
if err != nil || cluster == nil {
|
||||
return nil, err
|
||||
|
||||
@@ -43,6 +43,7 @@ const (
|
||||
NodeClusterField_HttpPages dbs.FieldName = "httpPages" // 自定义页面设置
|
||||
NodeClusterField_Cc dbs.FieldName = "cc" // CC设置
|
||||
NodeClusterField_Http3 dbs.FieldName = "http3" // HTTP3设置
|
||||
NodeClusterField_AutoSystemTuning dbs.FieldName = "autoSystemTuning" // 是否自动调整系统参数
|
||||
)
|
||||
|
||||
// NodeCluster 节点集群
|
||||
@@ -87,6 +88,7 @@ type NodeCluster struct {
|
||||
HttpPages dbs.JSON `field:"httpPages"` // 自定义页面设置
|
||||
Cc dbs.JSON `field:"cc"` // CC设置
|
||||
Http3 dbs.JSON `field:"http3"` // HTTP3设置
|
||||
AutoSystemTuning bool `field:"autoSystemTuning"` // 是否自动调整系统参数
|
||||
}
|
||||
|
||||
type NodeClusterOperator struct {
|
||||
@@ -130,6 +132,7 @@ type NodeClusterOperator struct {
|
||||
HttpPages any // 自定义页面设置
|
||||
Cc any // CC设置
|
||||
Http3 any // HTTP3设置
|
||||
AutoSystemTuning any // 是否自动调整系统参数
|
||||
}
|
||||
|
||||
func NewNodeClusterOperator() *NodeClusterOperator {
|
||||
|
||||
@@ -1218,6 +1218,7 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64, dataMap *shared
|
||||
// 自动安装nftables
|
||||
if clusterIndex == 0 {
|
||||
config.AutoInstallNftables = nodeCluster.AutoInstallNftables
|
||||
config.AutoSystemTuning = nodeCluster.AutoSystemTuning
|
||||
}
|
||||
|
||||
clusterIndex++
|
||||
|
||||
@@ -80,7 +80,7 @@ func (this *NodeClusterService) CreateNodeCluster(ctx context.Context, req *pb.C
|
||||
req.DnsTTL = 0
|
||||
}
|
||||
|
||||
clusterId, err = models.SharedNodeClusterDAO.CreateCluster(tx, adminId, req.Name, req.NodeGrantId, req.InstallDir, req.DnsDomainId, req.DnsName, req.DnsTTL, req.HttpCachePolicyId, req.HttpFirewallPolicyId, systemServices, serverGlobalConfig, req.AutoInstallNftables)
|
||||
clusterId, err = models.SharedNodeClusterDAO.CreateCluster(tx, adminId, req.Name, req.NodeGrantId, req.InstallDir, req.DnsDomainId, req.DnsName, req.DnsTTL, req.HttpCachePolicyId, req.HttpFirewallPolicyId, systemServices, serverGlobalConfig, req.AutoInstallNftables, req.AutoSystemTuning)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -127,7 +127,7 @@ func (this *NodeClusterService) UpdateNodeCluster(ctx context.Context, req *pb.U
|
||||
}
|
||||
}
|
||||
|
||||
err = models.SharedNodeClusterDAO.UpdateCluster(tx, req.NodeClusterId, req.Name, req.NodeGrantId, req.InstallDir, req.TimeZone, req.NodeMaxThreads, req.AutoOpenPorts, clockConfig, req.AutoRemoteStart, req.AutoInstallNftables, sshParams)
|
||||
err = models.SharedNodeClusterDAO.UpdateCluster(tx, req.NodeClusterId, req.Name, req.NodeGrantId, req.InstallDir, req.TimeZone, req.NodeMaxThreads, req.AutoOpenPorts, clockConfig, req.AutoRemoteStart, req.AutoInstallNftables, sshParams, req.AutoSystemTuning)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -233,6 +233,7 @@ func (this *NodeClusterService) FindEnabledNodeCluster(ctx context.Context, req
|
||||
ClockJSON: cluster.Clock,
|
||||
AutoRemoteStart: cluster.AutoRemoteStart,
|
||||
AutoInstallNftables: cluster.AutoInstallNftables,
|
||||
AutoSystemTuning: cluster.AutoSystemTuning,
|
||||
}}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -109766,7 +109766,7 @@
|
||||
"name": "edgeNodeClusters",
|
||||
"engine": "InnoDB",
|
||||
"charset": "utf8mb4_general_ci",
|
||||
"definition": "CREATE TABLE `edgeNodeClusters` (\n `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n `name` varchar(255) DEFAULT NULL COMMENT '名称',\n `useAllAPINodes` tinyint(1) unsigned DEFAULT '1' COMMENT '是否使用所有API节点',\n `apiNodes` json DEFAULT NULL COMMENT '使用的API节点',\n `installDir` varchar(512) DEFAULT NULL COMMENT '安装目录',\n `order` int(11) unsigned DEFAULT '0' COMMENT '排序',\n `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n `grantId` int(11) unsigned DEFAULT '0' COMMENT '默认认证方式',\n `sshParams` json DEFAULT NULL COMMENT 'SSH默认参数',\n `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n `autoRegister` tinyint(1) unsigned DEFAULT '1' COMMENT '是否开启自动注册',\n `uniqueId` varchar(32) DEFAULT NULL COMMENT '唯一ID',\n `secret` varchar(32) DEFAULT NULL COMMENT '密钥',\n `healthCheck` json DEFAULT NULL COMMENT '健康检查',\n `dnsName` varchar(255) DEFAULT NULL COMMENT 'DNS名称',\n `dnsDomainId` int(11) unsigned DEFAULT '0' COMMENT '域名ID',\n `dns` json DEFAULT NULL COMMENT 'DNS配置',\n `toa` json DEFAULT NULL COMMENT 'TOA配置',\n `cachePolicyId` int(11) unsigned DEFAULT '0' COMMENT '缓存策略ID',\n `httpFirewallPolicyId` int(11) unsigned DEFAULT '0' COMMENT 'WAF策略ID',\n `accessLog` json DEFAULT NULL COMMENT '访问日志设置',\n `systemServices` json DEFAULT NULL COMMENT '系统服务设置',\n `timeZone` varchar(64) DEFAULT NULL COMMENT '时区',\n `nodeMaxThreads` int(11) unsigned DEFAULT '0' COMMENT '节点最大线程数',\n `ddosProtection` json DEFAULT NULL COMMENT 'DDoS防护设置',\n `autoOpenPorts` tinyint(1) unsigned DEFAULT '1' COMMENT '是否自动尝试开放端口',\n `isPinned` tinyint(1) unsigned DEFAULT '0' COMMENT '是否置顶',\n `webp` json DEFAULT NULL COMMENT 'WebP设置',\n `uam` json DEFAULT NULL COMMENT 'UAM设置',\n `clock` json DEFAULT NULL COMMENT '时钟配置',\n `globalServerConfig` json DEFAULT NULL COMMENT '全局服务配置',\n `autoRemoteStart` tinyint(1) unsigned DEFAULT '1' COMMENT '自动远程启动',\n `autoInstallNftables` tinyint(1) unsigned DEFAULT '0' COMMENT '自动安装nftables',\n `isAD` tinyint(1) unsigned DEFAULT '0' COMMENT '是否为高防集群',\n `httpPages` json DEFAULT NULL COMMENT '自定义页面设置',\n `cc` json DEFAULT NULL COMMENT 'CC设置',\n `http3` json DEFAULT NULL COMMENT 'HTTP3设置',\n PRIMARY KEY (`id`),\n KEY `uniqueId` (`uniqueId`),\n KEY `grantId` (`grantId`),\n KEY `dnsDomainId` (`dnsDomainId`),\n KEY `cachePolicyId` (`cachePolicyId`),\n KEY `httpFirewallPolicyId` (`httpFirewallPolicyId`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点集群'",
|
||||
"definition": "CREATE TABLE `edgeNodeClusters` (\n `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n `name` varchar(255) DEFAULT NULL COMMENT '名称',\n `useAllAPINodes` tinyint(1) unsigned DEFAULT '1' COMMENT '是否使用所有API节点',\n `apiNodes` json DEFAULT NULL COMMENT '使用的API节点',\n `installDir` varchar(512) DEFAULT NULL COMMENT '安装目录',\n `order` int(11) unsigned DEFAULT '0' COMMENT '排序',\n `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n `grantId` int(11) unsigned DEFAULT '0' COMMENT '默认认证方式',\n `sshParams` json DEFAULT NULL COMMENT 'SSH默认参数',\n `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n `autoRegister` tinyint(1) unsigned DEFAULT '1' COMMENT '是否开启自动注册',\n `uniqueId` varchar(32) DEFAULT NULL COMMENT '唯一ID',\n `secret` varchar(32) DEFAULT NULL COMMENT '密钥',\n `healthCheck` json DEFAULT NULL COMMENT '健康检查',\n `dnsName` varchar(255) DEFAULT NULL COMMENT 'DNS名称',\n `dnsDomainId` int(11) unsigned DEFAULT '0' COMMENT '域名ID',\n `dns` json DEFAULT NULL COMMENT 'DNS配置',\n `toa` json DEFAULT NULL COMMENT 'TOA配置',\n `cachePolicyId` int(11) unsigned DEFAULT '0' COMMENT '缓存策略ID',\n `httpFirewallPolicyId` int(11) unsigned DEFAULT '0' COMMENT 'WAF策略ID',\n `accessLog` json DEFAULT NULL COMMENT '访问日志设置',\n `systemServices` json DEFAULT NULL COMMENT '系统服务设置',\n `timeZone` varchar(64) DEFAULT NULL COMMENT '时区',\n `nodeMaxThreads` int(11) unsigned DEFAULT '0' COMMENT '节点最大线程数',\n `ddosProtection` json DEFAULT NULL COMMENT 'DDoS防护设置',\n `autoOpenPorts` tinyint(1) unsigned DEFAULT '1' COMMENT '是否自动尝试开放端口',\n `isPinned` tinyint(1) unsigned DEFAULT '0' COMMENT '是否置顶',\n `webp` json DEFAULT NULL COMMENT 'WebP设置',\n `uam` json DEFAULT NULL COMMENT 'UAM设置',\n `clock` json DEFAULT NULL COMMENT '时钟配置',\n `globalServerConfig` json DEFAULT NULL COMMENT '全局服务配置',\n `autoRemoteStart` tinyint(1) unsigned DEFAULT '1' COMMENT '自动远程启动',\n `autoInstallNftables` tinyint(1) unsigned DEFAULT '0' COMMENT '自动安装nftables',\n `isAD` tinyint(1) unsigned DEFAULT '0' COMMENT '是否为高防集群',\n `httpPages` json DEFAULT NULL COMMENT '自定义页面设置',\n `cc` json DEFAULT NULL COMMENT 'CC设置',\n `http3` json DEFAULT NULL COMMENT 'HTTP3设置',\n `autoSystemTuning` tinyint(1) unsigned DEFAULT '1' COMMENT '是否自动调整系统参数',\n PRIMARY KEY (`id`),\n KEY `uniqueId` (`uniqueId`),\n KEY `grantId` (`grantId`),\n KEY `dnsDomainId` (`dnsDomainId`),\n KEY `cachePolicyId` (`cachePolicyId`),\n KEY `httpFirewallPolicyId` (`httpFirewallPolicyId`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点集群'",
|
||||
"fields": [
|
||||
{
|
||||
"name": "id",
|
||||
@@ -109927,6 +109927,10 @@
|
||||
{
|
||||
"name": "http3",
|
||||
"definition": "json COMMENT 'HTTP3设置'"
|
||||
},
|
||||
{
|
||||
"name": "autoSystemTuning",
|
||||
"definition": "tinyint(1) unsigned DEFAULT '1' COMMENT '是否自动调整系统参数'"
|
||||
}
|
||||
],
|
||||
"indexes": [
|
||||
|
||||
Reference in New Issue
Block a user