summaryrefslogtreecommitdiff
path: root/recording/runner.go
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-09-16 20:26:59 +0800
committerKeuin <[email protected]>2022-09-16 20:26:59 +0800
commit7d8ec5f208c645fef71e2b1fd9ce1f891edfda45 (patch)
treeae102ec8d89c2d526b2fe8a2d3af3c8ed0e33404 /recording/runner.go
parent0725ebf24da4d3f06097372e31c05a49543edc79 (diff)
Bugfix: Ctrl-C won't stop the task.
Diffstat (limited to 'recording/runner.go')
-rw-r--r--recording/runner.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/recording/runner.go b/recording/runner.go
index 8c1e047..f12e9cd 100644
--- a/recording/runner.go
+++ b/recording/runner.go
@@ -40,7 +40,11 @@ func (t *RunningTask) runTaskWithAutoRestart() {
t.status = StRunning
loop:
for {
- switch err := tryRunTask(t); err.(type) {
+ err := tryRunTask(t)
+ if errors.Is(err, context.Canceled) {
+ break
+ }
+ switch err.(type) {
case nil:
t.logger.Info("Task stopped: %v", t.String())
case *common.RecoverableTaskError:
@@ -49,9 +53,7 @@ loop:
}
t.status = StRestarting
default:
- if !errors.Is(err, context.Canceled) {
- t.logger.Error("Cannot recover from error: %v", err)
- }
+ t.logger.Error("Cannot recover from error: %v", err)
break loop
}
}
@@ -123,6 +125,10 @@ func tryRunTask(t *RunningTask) error {
liveStatusChecker,
t.logger,
)
+ // the context is cancelled
+ if errors.Is(err, context.Canceled) {
+ break loop
+ }
switch err.(type) {
case nil:
// live is started, stop watcher loop and start the recorder
@@ -139,10 +145,6 @@ func tryRunTask(t *RunningTask) error {
t.logger.Error("Error occurred in live status watcher: %v", err)
default:
run = false
- // the task is being cancelled
- if errors.Is(err, context.Canceled) {
- break loop
- }
// unknown error type, this should not happen
t.logger.Error("Unexpected type of error in watcher: %v", err)
}