mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-03 23:20:26 +08:00
集群设置增加自动硬盘TRIM选项
This commit is contained in:
@@ -12,5 +12,5 @@ dbs:
|
|||||||
|
|
||||||
|
|
||||||
fields:
|
fields:
|
||||||
bool: [ "uamIsOn", "followPort", "requestHostExcludingPort", "autoRemoteStart", "autoInstallNftables", "enableIPLists", "detectAgents", "checkingPorts", "enableRecordHealthCheck", "offlineIsNotified", "http2Enabled", "http3Enabled", "enableHTTP2", "retry50X", "retry40X", "autoSystemTuning", "disableDefaultDB" ]
|
bool: [ "uamIsOn", "followPort", "requestHostExcludingPort", "autoRemoteStart", "autoInstallNftables", "enableIPLists", "detectAgents", "checkingPorts", "enableRecordHealthCheck", "offlineIsNotified", "http2Enabled", "http3Enabled", "enableHTTP2", "retry50X", "retry40X", "autoSystemTuning", "disableDefaultDB", "autoTrimDisks" ]
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ func (this *NodeClusterDAO) FindAllEnableClusterIds(tx *dbs.Tx) (result []int64,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateCluster 创建集群
|
// 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, autoSystemTuning 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, autoTrimDisks bool) (clusterId int64, err error) {
|
||||||
uniqueId, err := this.GenUniqueId(tx)
|
uniqueId, err := this.GenUniqueId(tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@@ -190,6 +190,7 @@ func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string
|
|||||||
op.Secret = secret
|
op.Secret = secret
|
||||||
op.AutoInstallNftables = autoInstallNftables
|
op.AutoInstallNftables = autoInstallNftables
|
||||||
op.AutoSystemTuning = autoSystemTuning
|
op.AutoSystemTuning = autoSystemTuning
|
||||||
|
op.AutoTrimDisks = autoTrimDisks
|
||||||
op.State = NodeClusterStateEnabled
|
op.State = NodeClusterStateEnabled
|
||||||
err = this.Save(tx, op)
|
err = this.Save(tx, op)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -200,7 +201,7 @@ func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateCluster 修改集群
|
// 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, autoSystemTuning bool) 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, autoTrimDisks bool) error {
|
||||||
if clusterId <= 0 {
|
if clusterId <= 0 {
|
||||||
return errors.New("invalid clusterId")
|
return errors.New("invalid clusterId")
|
||||||
}
|
}
|
||||||
@@ -228,6 +229,7 @@ func (this *NodeClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name stri
|
|||||||
op.AutoRemoteStart = autoRemoteStart
|
op.AutoRemoteStart = autoRemoteStart
|
||||||
op.AutoInstallNftables = autoInstallTables
|
op.AutoInstallNftables = autoInstallTables
|
||||||
op.AutoSystemTuning = autoSystemTuning
|
op.AutoSystemTuning = autoSystemTuning
|
||||||
|
op.AutoTrimDisks = autoTrimDisks
|
||||||
|
|
||||||
if sshParams != nil {
|
if sshParams != nil {
|
||||||
sshParamsJSON, err := json.Marshal(sshParams)
|
sshParamsJSON, err := json.Marshal(sshParams)
|
||||||
@@ -1028,7 +1030,7 @@ func (this *NodeClusterDAO) FindClusterBasicInfo(tx *dbs.Tx, clusterId int64, ca
|
|||||||
cluster, err := this.Query(tx).
|
cluster, err := this.Query(tx).
|
||||||
Pk(clusterId).
|
Pk(clusterId).
|
||||||
State(NodeClusterStateEnabled).
|
State(NodeClusterStateEnabled).
|
||||||
Result("id", "name", "timeZone", "nodeMaxThreads", "cachePolicyId", "httpFirewallPolicyId", "autoOpenPorts", "webp", "uam", "cc", "httpPages", "http3", "isOn", "ddosProtection", "clock", "globalServerConfig", "autoInstallNftables", "autoSystemTuning", "networkSecurity").
|
Result("id", "name", "timeZone", "nodeMaxThreads", "cachePolicyId", "httpFirewallPolicyId", "autoOpenPorts", "webp", "uam", "cc", "httpPages", "http3", "isOn", "ddosProtection", "clock", "globalServerConfig", "autoInstallNftables", "autoSystemTuning", "networkSecurity", "autoTrimDisks").
|
||||||
Find()
|
Find()
|
||||||
if err != nil || cluster == nil {
|
if err != nil || cluster == nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ const (
|
|||||||
NodeClusterField_Http3 dbs.FieldName = "http3" // HTTP3设置
|
NodeClusterField_Http3 dbs.FieldName = "http3" // HTTP3设置
|
||||||
NodeClusterField_AutoSystemTuning dbs.FieldName = "autoSystemTuning" // 是否自动调整系统参数
|
NodeClusterField_AutoSystemTuning dbs.FieldName = "autoSystemTuning" // 是否自动调整系统参数
|
||||||
NodeClusterField_NetworkSecurity dbs.FieldName = "networkSecurity" // 网络安全策略
|
NodeClusterField_NetworkSecurity dbs.FieldName = "networkSecurity" // 网络安全策略
|
||||||
|
NodeClusterField_AutoTrimDisks dbs.FieldName = "autoTrimDisks" // 是否自动执行TRIM
|
||||||
)
|
)
|
||||||
|
|
||||||
// NodeCluster 节点集群
|
// NodeCluster 节点集群
|
||||||
@@ -91,6 +92,7 @@ type NodeCluster struct {
|
|||||||
Http3 dbs.JSON `field:"http3"` // HTTP3设置
|
Http3 dbs.JSON `field:"http3"` // HTTP3设置
|
||||||
AutoSystemTuning bool `field:"autoSystemTuning"` // 是否自动调整系统参数
|
AutoSystemTuning bool `field:"autoSystemTuning"` // 是否自动调整系统参数
|
||||||
NetworkSecurity dbs.JSON `field:"networkSecurity"` // 网络安全策略
|
NetworkSecurity dbs.JSON `field:"networkSecurity"` // 网络安全策略
|
||||||
|
AutoTrimDisks bool `field:"autoTrimDisks"` // 是否自动执行TRIM
|
||||||
}
|
}
|
||||||
|
|
||||||
type NodeClusterOperator struct {
|
type NodeClusterOperator struct {
|
||||||
@@ -136,6 +138,7 @@ type NodeClusterOperator struct {
|
|||||||
Http3 any // HTTP3设置
|
Http3 any // HTTP3设置
|
||||||
AutoSystemTuning any // 是否自动调整系统参数
|
AutoSystemTuning any // 是否自动调整系统参数
|
||||||
NetworkSecurity any // 网络安全策略
|
NetworkSecurity any // 网络安全策略
|
||||||
|
AutoTrimDisks any // 是否自动执行TRIM
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNodeClusterOperator() *NodeClusterOperator {
|
func NewNodeClusterOperator() *NodeClusterOperator {
|
||||||
|
|||||||
@@ -1244,10 +1244,11 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64, dataMap *shared
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自动安装nftables
|
// 自动安装nftables等集群配置
|
||||||
if clusterIndex == 0 {
|
if clusterIndex == 0 {
|
||||||
config.AutoInstallNftables = nodeCluster.AutoInstallNftables
|
config.AutoInstallNftables = nodeCluster.AutoInstallNftables
|
||||||
config.AutoSystemTuning = nodeCluster.AutoSystemTuning
|
config.AutoSystemTuning = nodeCluster.AutoSystemTuning
|
||||||
|
config.AutoTrimDisks = nodeCluster.AutoTrimDisks
|
||||||
}
|
}
|
||||||
|
|
||||||
// 安全设置
|
// 安全设置
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ func (this *NodeClusterService) CreateNodeCluster(ctx context.Context, req *pb.C
|
|||||||
req.DnsTTL = 0
|
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, req.AutoSystemTuning)
|
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, req.AutoTrimDisks)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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, req.AutoSystemTuning)
|
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, req.AutoTrimDisks)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -234,6 +234,7 @@ func (this *NodeClusterService) FindEnabledNodeCluster(ctx context.Context, req
|
|||||||
AutoRemoteStart: cluster.AutoRemoteStart,
|
AutoRemoteStart: cluster.AutoRemoteStart,
|
||||||
AutoInstallNftables: cluster.AutoInstallNftables,
|
AutoInstallNftables: cluster.AutoInstallNftables,
|
||||||
AutoSystemTuning: cluster.AutoSystemTuning,
|
AutoSystemTuning: cluster.AutoSystemTuning,
|
||||||
|
AutoTrimDisks: cluster.AutoTrimDisks,
|
||||||
}}, nil
|
}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user