Skip to content

Commit

Permalink
fix: use signal recovery mode
Browse files Browse the repository at this point in the history
  • Loading branch information
starudream committed Dec 27, 2023
1 parent 63875d6 commit fac24ac
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions job/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/starudream/go-lib/core/v2/slog"
"github.com/starudream/go-lib/core/v2/utils/fmtutil"
"github.com/starudream/go-lib/core/v2/utils/maputil"
"github.com/starudream/go-lib/core/v2/utils/signalutil"
"github.com/starudream/go-lib/tablew/v2"

"github.com/starudream/clash-speedtest/api/clash"
Expand Down Expand Up @@ -87,11 +88,16 @@ func Run() error {
if err != nil {
return err
}
go func() {
<-signalutil.Defer(func() {
err = t.clash.SetMode(t.config.Mode)
if err != nil {
slog.Error("set mode error: %v", err)
}
}).Done()
}()

defer func(start time.Time) {
err = t.clash.SetMode(t.config.Mode)
if err != nil {
slog.Error("set mode error: %v", err)
}
slog.Info("took %s", time.Since(start).Truncate(time.Millisecond))
}(time.Now())

Expand Down

0 comments on commit fac24ac

Please sign in to comment.