1
0
Fork 0
refactor/models
Matthew 2019-12-19 00:02:59 -05:00
parent 338f880bd4
commit de6ed2d37f
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 9 additions and 4 deletions

View File

@ -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)
} }