feat: add compress command
This commit is contained in:
@@ -57,22 +57,23 @@ func Serve(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
log.Infof("start compressing %s", args[0])
|
log.Infof("start compressing %s", args[0])
|
||||||
|
|
||||||
if err := commandCompress(args[0]); err != nil {
|
failTimes := 0
|
||||||
log.WithError(err).Errorf("compressing %s failed", args[0])
|
for {
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
ticker := time.NewTicker(5 * time.Minute)
|
|
||||||
for range ticker.C {
|
|
||||||
log.Infof("start compressing %s", args[0])
|
log.Infof("start compressing %s", args[0])
|
||||||
|
|
||||||
if err := commandCompress(args[0]); err != nil {
|
if err := commandCompress(args[0]); err != nil {
|
||||||
log.WithError(err).Errorf("compressing %s failed", args[0])
|
log.WithError(err).Errorf("compressing %s failed", args[0])
|
||||||
|
failTimes++
|
||||||
|
|
||||||
|
if failTimes >= 3 {
|
||||||
|
return errors.New("failed to compress after 3 attempts")
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Infof("compressing %s done", args[0])
|
log.Infof("compressing %s done", args[0])
|
||||||
|
|
||||||
|
time.Sleep(5 * time.Minute)
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func commandCompress(dir string) error {
|
func commandCompress(dir string) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user