mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-20 18:55:52 +08:00
Merge pull request #669 from gravitl/refactor_v0.10.0_logs
Refactor v0.10.0 logs
This commit is contained in:
commit
cf6bb710f7
4 changed files with 26 additions and 26 deletions
|
@ -1,9 +0,0 @@
|
||||||
#first stage - builder
|
|
||||||
FROM golang:1.17
|
|
||||||
ARG version
|
|
||||||
WORKDIR /app
|
|
||||||
COPY . .
|
|
||||||
ENV GO111MODULE=auto
|
|
||||||
|
|
||||||
# RUN GOOS=linux CGO_ENABLED=1 go build -tags debug -ldflags="-s -X 'main.version=$version'" -o netmaker main.go
|
|
||||||
RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -X 'main.version=$version'" -o netmaker main.go
|
|
|
@ -1,14 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#Source this file if using default mongo settings from readme
|
|
||||||
# if i've done my work correctly, this file will be defunct
|
|
||||||
# refer to config folder for new method
|
|
||||||
export API_PORT=8081
|
|
||||||
export GRPC_PORT=50051
|
|
||||||
export MONGO_USER=mongoadmin
|
|
||||||
export MONGO_PASS=mongopass
|
|
||||||
export MONGO_HOST=localhost
|
|
||||||
export MASTER_KEY=c4tsRc001
|
|
||||||
export MONGO_PORT=27017
|
|
||||||
export MONGO_OPTS='/?authSource=admin'
|
|
||||||
export MASTER_TOKEN="mastertoken"
|
|
||||||
export CREATE_KEY="newnode123"
|
|
|
@ -1,7 +1,6 @@
|
||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -156,7 +155,7 @@ func Push(cfg config.ClientConfig) error {
|
||||||
for _, network := range networks {
|
for _, network := range networks {
|
||||||
err = functions.Push(network)
|
err = functions.Push(network)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error pushing network configs for "+network+" network: ", err)
|
ncutils.PrintLog("error pushing network configs for network: "+network+"\n"+err.Error(), 1)
|
||||||
} else {
|
} else {
|
||||||
ncutils.PrintLog("pushed network config for "+network, 1)
|
ncutils.PrintLog("pushed network config for "+network, 1)
|
||||||
}
|
}
|
||||||
|
@ -187,7 +186,7 @@ func Pull(cfg config.ClientConfig) error {
|
||||||
for _, network := range networks {
|
for _, network := range networks {
|
||||||
_, err = functions.Pull(network, true)
|
_, err = functions.Pull(network, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error pulling network config for "+network+" network: ", err)
|
ncutils.PrintLog("Error pulling network config for network: "+network+"\n"+err.Error(), 1)
|
||||||
} else {
|
} else {
|
||||||
ncutils.PrintLog("pulled network config for "+network, 1)
|
ncutils.PrintLog("pulled network config for "+network, 1)
|
||||||
}
|
}
|
||||||
|
|
24
netclient/ncutils/util.go
Normal file
24
netclient/ncutils/util.go
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
package ncutils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BackOff - back off any function while there is an error
|
||||||
|
func BackOff(isExponential bool, maxTime int, f interface{}) (interface{}, error) {
|
||||||
|
// maxTime seconds
|
||||||
|
startTime := time.Now()
|
||||||
|
sleepTime := time.Second
|
||||||
|
for time.Now().Before(startTime.Add(time.Second * time.Duration(maxTime))) {
|
||||||
|
if result, err := f.(func() (interface{}, error))(); err == nil {
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
time.Sleep(sleepTime)
|
||||||
|
if isExponential {
|
||||||
|
sleepTime = sleepTime << 1
|
||||||
|
}
|
||||||
|
PrintLog("retrying...", 1)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("could not find result")
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue