mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-10 08:20:24 +08:00
可以远程停止和启动DNS节点
This commit is contained in:
@@ -31,6 +31,8 @@ func init() {
|
|||||||
GetPost("/install", new(node.InstallAction)).
|
GetPost("/install", new(node.InstallAction)).
|
||||||
Post("/status", new(node.StatusAction)).
|
Post("/status", new(node.StatusAction)).
|
||||||
Post("/updateInstallStatus", new(node.UpdateInstallStatusAction)).
|
Post("/updateInstallStatus", new(node.UpdateInstallStatusAction)).
|
||||||
|
Post("/start", new(node.StartAction)).
|
||||||
|
Post("/stop", new(node.StopAction)).
|
||||||
EndAll()
|
EndAll()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
"isOn": node.IsOn,
|
"isOn": node.IsOn,
|
||||||
|
|
||||||
"status": maps.Map{
|
"status": maps.Map{
|
||||||
"isActive": status.IsActive,
|
"isActive": node.IsActive && status.IsActive,
|
||||||
"updatedAt": status.UpdatedAt,
|
"updatedAt": status.UpdatedAt,
|
||||||
"hostname": status.Hostname,
|
"hostname": status.Hostname,
|
||||||
"cpuUsage": status.CPUUsage,
|
"cpuUsage": status.CPUUsage,
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package node
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
)
|
||||||
|
|
||||||
|
type StartAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *StartAction) RunPost(params struct {
|
||||||
|
NodeId int64
|
||||||
|
}) {
|
||||||
|
resp, err := this.RPC().NSNodeRPC().StartNSNode(this.AdminContext(), &pb.StartNSNodeRequest{NsNodeId: params.NodeId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建日志
|
||||||
|
defer this.CreateLog(oplogs.LevelInfo, "远程启动节点 %d", params.NodeId)
|
||||||
|
|
||||||
|
if resp.IsOk {
|
||||||
|
this.Success()
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Fail("启动失败:" + resp.Error)
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package node
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
)
|
||||||
|
|
||||||
|
type StopAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *StopAction) RunPost(params struct {
|
||||||
|
NodeId int64
|
||||||
|
}) {
|
||||||
|
resp, err := this.RPC().NSNodeRPC().StopNSNode(this.AdminContext(), &pb.StopNSNodeRequest{NsNodeId: params.NodeId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建日志
|
||||||
|
defer this.CreateLog(oplogs.LevelInfo, "远程停止节点 %d", params.NodeId)
|
||||||
|
|
||||||
|
if resp.IsOk {
|
||||||
|
this.Success()
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Fail("执行失败:" + resp.Error)
|
||||||
|
}
|
||||||
@@ -39,12 +39,12 @@
|
|||||||
<td>
|
<td>
|
||||||
<div v-if="node.status.isActive">
|
<div v-if="node.status.isActive">
|
||||||
<span class="green">运行中</span>
|
<span class="green">运行中</span>
|
||||||
<!--<a href="" @click.prevent="stopNode()" v-if="!isStopping"><span>[通过SSH停止]</span></a>-->
|
<a href="" @click.prevent="stopNode()" v-if="!isStopping"><span>[通过SSH停止]</span></a>
|
||||||
<span v-if="isStopping">[停止中...]</span>
|
<span v-if="isStopping">[停止中...]</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<span class="red">已断开</span>
|
<span class="red">已断开</span>
|
||||||
<!--<a href="" @click.prevent="startNode()" v-if="node.isInstalled && !isStarting"><span>[通过SSH启动]</span></a>-->
|
<a href="" @click.prevent="startNode()" v-if="node.isInstalled && !isStarting"><span>[通过SSH启动]</span></a>
|
||||||
<span v-if="node.isInstalled && isStarting">[启动中...]</span>
|
<span v-if="node.isInstalled && isStarting">[启动中...]</span>
|
||||||
<a v-if="!node.isInstalled" :href="'/ns/clusters/cluster/node/install?clusterId=' + clusterId + '&nodeId=' + node.id" ><span>去安装></span></a>
|
<a v-if="!node.isInstalled" :href="'/ns/clusters/cluster/node/install?clusterId=' + clusterId + '&nodeId=' + node.id" ><span>去安装></span></a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user