代码拉取完成,页面将自动刷新
// +build agent
// replication-manager - Replication Manager Monitoring and CLI for MariaDB and MySQL
// Copyright 2017 Signal 18 SARL
// Authors: Guillaume Lefranc <guillaume@signal18.io>
// Stephane Varoqui <svaroqui@gmail.com>
// This source code is licensed under the GNU General Public License, version 3.
// Redistribution/Reuse of this code is permitted under the GNU v3 license, as
// an additional term, ALL code must carry the original Author(s) credit in comment form.
// See LICENSE in this directory for the integral text.
package main
import (
// "encoding/json"
"encoding/json"
"log"
"net/http"
// "os"
// "strings"
"github.com/signal18/replication-manager/cluster"
"github.com/spf13/cobra"
// "github.com/signal18/replication-manager/misc"
)
func init() {
rootCmd.AddCommand(agentCmd)
}
var agentCmd = &cobra.Command{
Use: "agent",
Short: "Starts replication monitoring agent",
Long: `The replication monitoring agent is used by the failover monitor to
take consensus decisions`,
Run: func(cmd *cobra.Command, args []string) {
http.HandleFunc("/agent/", handlerAgent)
log.Println("Starting agent on port 10001")
http.ListenAndServe("0.0.0.0:10001", nil)
},
}
func handlerAgent(w http.ResponseWriter, r *http.Request) {
currentCluster = new(cluster.Cluster)
err := currentCluster.InitAgent(conf)
e := json.NewEncoder(w)
err = e.Encode(db)
if err != nil {
log.Println("Error encoding JSON: ", err)
http.Error(w, "Encoding error", 500)
return
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。