diff --git a/src/go/storage/storage.go b/src/go/storage/storage.go index dabfd4c..67d18ff 100644 --- a/src/go/storage/storage.go +++ b/src/go/storage/storage.go @@ -8,7 +8,6 @@ import ( "os" "strings" "time" - "sync" "github.com/go-redis/redis/v7" "go.mongodb.org/mongo-driver/bson" @@ -83,20 +82,18 @@ func handler(config ConfigStruct) { cur, err := collection.Find(context.TODO(), bson.D{}) HandleError(err, 0) - var wg sync.WaitGroup for cur.Next(context.TODO()) { - wg.Add(1) - go checkAccountSizeAndUpdate(cur.Current.Lookup("username").String(), cur.Current.Lookup("id").String(), &wg) + 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(10 * time.Second) } - wg.Wait() err = mongoClient.Disconnect(ctx) HandleError(err, 1) fmt.Println("CSD-GO-STR finished, exiting with code 0. [GO]") os.Exit(0) } -func checkAccountSizeAndUpdate(username string, id string, wg *sync.WaitGroup) { +func checkAccountSizeAndUpdate(username string, id string) { var size float64 = 0 var userHomeDirectory string = strings.Replace(strings.Join([]string{"/home/", string(username)}, ""), "\"", "", -1) usernameFormat := strings.Replace(username, "\"", "", -1) @@ -108,5 +105,4 @@ func checkAccountSizeAndUpdate(username string, id string, wg *sync.WaitGroup) { fmt.Println(status.Err()) } fmt.Printf("Set Call | Username: %v, ID: %v | Bytes: %f [GO]\n", string(username), string(id), size) - wg.Done() } diff --git a/src/intervals/storage.ts b/src/intervals/storage.ts index 77bc29d..ebd669e 100644 --- a/src/intervals/storage.ts +++ b/src/intervals/storage.ts @@ -20,6 +20,7 @@ export default async function storage(client: Client) { client.signale.log(`CSD-GO-STR Daemon exited with code ${code}.`); storageDaemon.removeAllListeners(); client.signale.info(`Reactivating CSD-GO-STR daemon startup interval. Reactivating in ${intervalTiming / 60000}min.`); + storageDaemon.kill(); }); } /* let storageGo = spawn(`${__dirname}/../bin/storage`, [], { cwd: __dirname });