cleanup code
This commit is contained in:
17
app/app.go
17
app/app.go
@@ -7,6 +7,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/luthermonson/go-proxmox"
|
||||
@@ -18,6 +19,7 @@ var client ProxmoxClient
|
||||
|
||||
func Run() {
|
||||
gob.Register(proxmox.Client{})
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
|
||||
configPath := flag.String("config", "config.json", "path to config.json file")
|
||||
flag.Parse()
|
||||
@@ -34,6 +36,21 @@ func Run() {
|
||||
cluster.Init(client)
|
||||
cluster.Rebuild()
|
||||
|
||||
// set repeating update for full rebuilds
|
||||
ticker := time.NewTicker(5 * time.Second)
|
||||
channel := make(chan bool)
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-channel:
|
||||
return
|
||||
case <-ticker.C:
|
||||
cluster.Rebuild()
|
||||
log.Printf("rebuilt cluster\n")
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
router.GET("/version", func(c *gin.Context) {
|
||||
PVEVersion, err := client.Version()
|
||||
if err != nil {
|
||||
|
@@ -17,7 +17,6 @@ func (cluster *Cluster) Init(pve ProxmoxClient) {
|
||||
|
||||
func (cluster *Cluster) Rebuild() error {
|
||||
cluster.Hosts = make(map[string]*Host)
|
||||
//cluster.Instance = make(map[uint]*Instance)
|
||||
|
||||
// get all nodes
|
||||
nodes, err := cluster.pve.Nodes()
|
||||
|
Reference in New Issue
Block a user