Skip to content

Commit

Permalink
remove pointless assignment, fix logs/errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vmorganp committed Aug 29, 2022
1 parent 61a3c2b commit 9823afa
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lazytainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ func main() {
rxHistory := make([]int, int(math.Ceil(float64(inactiveTimeout/pollRate))))
sleepTime := time.Duration(pollRate) * time.Second
for {
rxPackets := getRxPackets()
rxHistory = append(rxHistory[1:], rxPackets)
rxHistory = append(rxHistory[1:], getRxPackets())
if rxHistory[0] > rxHistory[len(rxHistory)-1] {
rxHistory = make([]int, int(math.Ceil(float64(inactiveTimeout/pollRate))))
if verbose {
Expand All @@ -43,7 +42,7 @@ func main() {
}
// if no clients are active on ports and threshhold packets haven't been recieved in TIMEOUT secs
if getActiveClients() == 0 && rxHistory[0]+minPacketThreshold > rxHistory[len(rxHistory)-1] {
// count up if we have no active clients
// count up if no active clients
inactiveSeconds = inactiveSeconds + pollRate
fmt.Println(inactiveSeconds, "/", inactiveTimeout, "seconds without an active client or sufficient traffic on running container")
if inactiveSeconds >= inactiveTimeout {
Expand All @@ -59,7 +58,7 @@ func main() {
startContainers()
} else {
if verbose {
fmt.Println(rxHistory[len(rxHistory)-1], "recieved out of ", rxHistory[0]+minPacketThreshold, "packets needed to restart container")
fmt.Println(rxHistory[len(rxHistory)-1], "recieved out of", rxHistory[0]+minPacketThreshold, "packets needed to restart container")
}
}
}
Expand All @@ -78,7 +77,7 @@ func setVarsFromEnv() {

portsCSV := os.Getenv("PORT")
if portsCSV == "" {
panic("you must set env variable PORTS")
panic("you must set env variable PORT")
}
// ports to check for active connections
portsArray := strings.Split(string(strings.TrimSpace(string(portsCSV))), ",")
Expand Down

0 comments on commit 9823afa

Please sign in to comment.