mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-10 01:10:29 +08:00
配置更新时立即向集群节点发消息
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package common
|
||||
package clusters
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
@@ -8,15 +8,15 @@ import (
|
||||
)
|
||||
|
||||
// 检查变更的集群列表
|
||||
type ChangedClustersAction struct {
|
||||
type CheckChangeAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *ChangedClustersAction) Init() {
|
||||
func (this *CheckChangeAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *ChangedClustersAction) RunGet(params struct {
|
||||
func (this *CheckChangeAction) RunPost(params struct {
|
||||
IsNotifying bool
|
||||
}) {
|
||||
timeout := time.NewTimer(55 * time.Second) // 比客户端提前结束,避免在客户端产生一个请求错误
|
||||
@@ -13,6 +13,8 @@ func init() {
|
||||
Prefix("/clusters").
|
||||
Get("", new(IndexAction)).
|
||||
GetPost("/create", new(CreateAction)).
|
||||
Post("/sync", new(SyncAction)).
|
||||
Post("/checkChange", new(CheckChangeAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
package common
|
||||
package clusters
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/nodeutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/messageconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
// 同步集群
|
||||
type SyncClustersAction struct {
|
||||
type SyncAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *SyncClustersAction) RunPost(params struct{}) {
|
||||
func (this *SyncAction) RunPost(params struct{}) {
|
||||
// TODO 将来可以单独选择某一个集群进行单独的同步
|
||||
|
||||
// 所有有变化的集群
|
||||
@@ -29,6 +31,13 @@ func (this *SyncClustersAction) RunPost(params struct{}) {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
// 发送通知
|
||||
_, err = nodeutils.SendMessageToCluster(this.AdminContext(), cluster.Id, messageconfigs.MessageCodeConfigChanged, &messageconfigs.ConfigChangedMessage{}, 10)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this.Success()
|
||||
@@ -1,17 +0,0 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(new(helpers.UserMustAuth)).
|
||||
Prefix("/common").
|
||||
Get("/changedClusters", new(ChangedClustersAction)).
|
||||
Post("/syncClusters", new(SyncClustersAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
@@ -97,6 +97,7 @@ func (this *IndexAction) RunGet(params struct{}) {
|
||||
|
||||
serverMaps = append(serverMaps, maps.Map{
|
||||
"id": server.Id,
|
||||
"isOn": server.IsOn,
|
||||
"name": server.Name,
|
||||
"cluster": maps.Map{
|
||||
"id": server.Cluster.Id,
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/settings"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/common"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dashboard"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/db"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dns"
|
||||
|
||||
@@ -37,7 +37,7 @@ Tea.context(function () {
|
||||
* 检查集群变更
|
||||
*/
|
||||
this.checkClusterChanges = function () {
|
||||
this.$get("/common/changedClusters")
|
||||
this.$post("/clusters/checkChange")
|
||||
.params({
|
||||
isNotifying: (this.globalChangedClusters.length > 0) ? 1 : 0
|
||||
})
|
||||
@@ -64,7 +64,7 @@ Tea.context(function () {
|
||||
*/
|
||||
this.syncClustersConfigs = function () {
|
||||
teaweb.confirm("确定要同步集群服务配置吗?", function () {
|
||||
this.$post("/common/syncClusters")
|
||||
this.$post("/clusters/sync")
|
||||
.success(function () {
|
||||
this.globalChangedClusters = [];
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<second-menu>
|
||||
<menu-item :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + nodeId" code="node">节点详情</menu-item>
|
||||
<menu-item :href="'/clusters/cluster/node/logs?clusterId=' + clusterId + '&nodeId=' + nodeId" code="log">节点日志</menu-item>
|
||||
<menu-item :href="'/clusters/cluster/node/update?clusterId=' + clusterId + '&nodeId=' + nodeId" code="update">修改节点</menu-item>
|
||||
<menu-item :href="'/clusters/cluster/node/logs?clusterId=' + clusterId + '&nodeId=' + nodeId" code="log">运行日志</menu-item>
|
||||
<menu-item :href="'/clusters/cluster/node/update?clusterId=' + clusterId + '&nodeId=' + nodeId" code="update">修改设置</menu-item>
|
||||
<menu-item :href="'/clusters/cluster/node/install?clusterId=' + clusterId + '&nodeId=' + nodeId" code="install">安装节点</menu-item>
|
||||
</second-menu>
|
||||
5
web/views/@default/clusters/cluster/node/logs.css
Normal file
5
web/views/@default/clusters/cluster/node/logs.css
Normal file
@@ -0,0 +1,5 @@
|
||||
pre.log-box {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
/*# sourceMappingURL=logs.css.map */
|
||||
1
web/views/@default/clusters/cluster/node/logs.css.map
Normal file
1
web/views/@default/clusters/cluster/node/logs.css.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["logs.less"],"names":[],"mappings":"AAAA,GAAG;EACF,SAAA;EACA,UAAA","file":"logs.css"}
|
||||
@@ -14,10 +14,7 @@
|
||||
</thead>
|
||||
<tr v-for="log in logs">
|
||||
<td>
|
||||
<span :class="{red:log.level == 'error', yellow:log.level == 'warning'}">
|
||||
<span v-if="!log.isToday">[{{log.createdTime}}]</span>
|
||||
<strong v-if="log.isToday">[{{log.createdTime}}]</strong>
|
||||
[{{log.tag}}]{{log.description}}</span>
|
||||
<pre class="log-box"><span :class="{red:log.level == 'error', yellow:log.level == 'warning'}"><span v-if="!log.isToday">[{{log.createdTime}}]</span><strong v-if="log.isToday">[{{log.createdTime}}]</strong>[{{log.tag}}]{{log.description}}</span></pre>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
4
web/views/@default/clusters/cluster/node/logs.less
Normal file
4
web/views/@default/clusters/cluster/node/logs.less
Normal file
@@ -0,0 +1,4 @@
|
||||
pre.log-box {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
@@ -9,10 +9,8 @@
|
||||
<th>服务名称</th>
|
||||
<th>服务类型</th>
|
||||
<th>部署集群</th>
|
||||
<th>运行中节点数</th>
|
||||
<th>未运行节点数</th>
|
||||
<th>端口</th>
|
||||
<th>状态</th>
|
||||
<th class="two wide">状态</th>
|
||||
<th class="two op">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -20,8 +18,6 @@
|
||||
<td>{{server.name}}</td>
|
||||
<td>{{server.serverTypeName}}</td>
|
||||
<td>{{server.cluster.name}}</td>
|
||||
<td><span class="disabled">[暂无]</span></td>
|
||||
<td><span class="disabled">[暂无]</span></td>
|
||||
<td>
|
||||
<span v-if="server.ports.length == 0">-</span>
|
||||
<div v-for="port in server.ports">
|
||||
@@ -29,7 +25,7 @@
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span class="disabled">[暂无]</span>
|
||||
<label-on :v-is-on="server.isOn"></label-on>
|
||||
</td>
|
||||
<td>
|
||||
<a :href="'/servers/server?serverId=' + server.id">详情</a>
|
||||
|
||||
Reference in New Issue
Block a user