forked from engineering/cloudservices
logs
parent
338f880bd4
commit
de6ed2d37f
|
@ -52,6 +52,7 @@ func main() {
|
||||||
err = client.Connect(ctx)
|
err = client.Connect(ctx)
|
||||||
HandleError(err, 1)
|
HandleError(err, 1)
|
||||||
err = client.Ping(context.TODO(), nil)
|
err = client.Ping(context.TODO(), nil)
|
||||||
|
fmt.Printf("Connected to MongoDB [GO]\n")
|
||||||
HandleError(err, 1)
|
HandleError(err, 1)
|
||||||
|
|
||||||
RedisClient = redis.NewClient(&redis.Options{
|
RedisClient = redis.NewClient(&redis.Options{
|
||||||
|
@ -61,10 +62,12 @@ func main() {
|
||||||
})
|
})
|
||||||
|
|
||||||
_, err = RedisClient.Ping().Result()
|
_, err = RedisClient.Ping().Result()
|
||||||
|
fmt.Printf("Connected to Redis [GO]\n")
|
||||||
HandleError(err, 1)
|
HandleError(err, 1)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
handler()
|
handler()
|
||||||
|
fmt.Printf("Calling handler func [GO]\n")
|
||||||
time.Sleep(1000000 * time.Second)
|
time.Sleep(1000000 * time.Second)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,6 +78,7 @@ func handler() {
|
||||||
|
|
||||||
for cur.Next(context.TODO()) {
|
for cur.Next(context.TODO()) {
|
||||||
go checkAccountSizeAndUpdate(cur.Current.Lookup("username").String(), cur.Current.Lookup("id").String())
|
go checkAccountSizeAndUpdate(cur.Current.Lookup("username").String(), cur.Current.Lookup("id").String())
|
||||||
|
fmt.Printf("Checking account information for %s\n", cur.Current.Lookup("username").String())
|
||||||
time.Sleep(600000 * time.Second)
|
time.Sleep(600000 * time.Second)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,4 +90,5 @@ func checkAccountSizeAndUpdate(username string, id string) {
|
||||||
sizeMail := DirSize("/var/mail/" + username)
|
sizeMail := DirSize("/var/mail/" + username)
|
||||||
bytes += sizeMail
|
bytes += sizeMail
|
||||||
RedisClient.Set("storage"+"-"+id, bytes, 0)
|
RedisClient.Set("storage"+"-"+id, bytes, 0)
|
||||||
|
fmt.Printf("Set Call | Username: %v, ID: %v | Bytes: %f\n", username, id, bytes)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue