This commit is contained in:
parent
047e859efa
commit
e304781ba3
@ -59,6 +59,12 @@ func main() {
|
|||||||
}).Fatal(fmt.Sprintf("Error spawning new agent: %s", err.Error()))
|
}).Fatal(fmt.Sprintf("Error spawning new agent: %s", err.Error()))
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
|
server, err = hetzner.RefreshNodeInfo(cfg, server.ID)
|
||||||
|
if err != nil {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"Caller": "Main",
|
||||||
|
}).Fatal(fmt.Sprintf("Failed to start Agent: %s", err.Error()))
|
||||||
|
}
|
||||||
if server.Status == hcloud.ServerStatusRunning {
|
if server.Status == hcloud.ServerStatusRunning {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"Caller": "Main",
|
"Caller": "Main",
|
||||||
|
@ -134,3 +134,12 @@ func DecomNode(cfg *config.Config, server *hcloud.Server) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RefreshNodeInfo(cfg *config.Config, serverID int) (*hcloud.Server, error) {
|
||||||
|
client := hcloud.NewClient(hcloud.WithToken(cfg.HcloudToken))
|
||||||
|
server, _, err := client.Server.GetByID(context.Background(), serverID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.New(fmt.Sprintf("Could not refresh server info: %s", err.Error()))
|
||||||
|
}
|
||||||
|
return server, nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user