feat: update compress ticker
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package queue
|
||||
package commands
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"quyun/app/service"
|
||||
|
||||
@@ -50,16 +51,21 @@ type compressedDB struct {
|
||||
}
|
||||
|
||||
func Serve(cmd *cobra.Command, args []string) error {
|
||||
log.SetFormatter(&log.JSONFormatter{})
|
||||
|
||||
// log.SetFormatter(&log.JSONFormatter{})
|
||||
if len(args) == 0 {
|
||||
return errors.New("usage: compress <path>")
|
||||
return errors.New("usage: compress path")
|
||||
}
|
||||
|
||||
if err := commandCompress(args[0]); err != nil {
|
||||
return err
|
||||
}
|
||||
ticker := time.NewTicker(5 * time.Minute)
|
||||
for range ticker.C {
|
||||
log.Infof("compressing %s", args[0])
|
||||
|
||||
if err := commandCompress(args[0]); err != nil {
|
||||
log.WithError(err).Errorf("compressing %s failed", args[0])
|
||||
continue
|
||||
}
|
||||
log.Infof("compressing %s done", args[0])
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package queue
|
||||
package commands
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"quyun/app/service/commands"
|
||||
"quyun/app/service/http"
|
||||
"quyun/app/service/migrate"
|
||||
|
||||
@@ -27,6 +28,7 @@ func main() {
|
||||
atom.Name("quyun"),
|
||||
http.Command(),
|
||||
migrate.Command(),
|
||||
commands.Command(),
|
||||
}
|
||||
|
||||
if err := atom.Serve(opts...); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user