Set Health status based on healthcheck status
This commit is contained in:
parent
c7df166a2d
commit
5413d2e7aa
1 changed files with 15 additions and 2 deletions
|
@ -213,6 +213,21 @@ func updateWorkerTaskStatus(ctx context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ts.Task.Type == constants.TASK_TYPE_HEALTHCHECK && (ts.Task.Status == constants.TASK_STATUS_FAILED || ts.Task.Status == constants.TASK_STATUS_SUCCESS) {
|
||||||
|
var health constants.FileHealth
|
||||||
|
if ts.Task.Status == constants.TASK_STATUS_SUCCESS {
|
||||||
|
health = constants.FILE_HEALTH_HEALTHY
|
||||||
|
} else {
|
||||||
|
// TODO, not all failures mean the file is damaged, only update on success and track ffmpeg errors in task result data. also remove -xerror and scan for errors manually to see all problems in logs
|
||||||
|
health = constants.FILE_HEALTH_DAMAGED
|
||||||
|
}
|
||||||
|
_, err = db.Exec(ctx, "UPDATE files SET health = $2 WHERE id = $1", ts.Task.FileID, health)
|
||||||
|
if err != nil {
|
||||||
|
slog.ErrorContext(ctx, "Error Updating File health", "err", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tell Worker to Delete Finished Tasks
|
// Tell Worker to Delete Finished Tasks
|
||||||
if ts.Task.Status == constants.TASK_STATUS_FAILED || ts.Task.Status == constants.TASK_STATUS_SUCCESS {
|
if ts.Task.Status == constants.TASK_STATUS_FAILED || ts.Task.Status == constants.TASK_STATUS_SUCCESS {
|
||||||
_, err := rpcServer.Call(ctx, w.Conn, "task-delete", ts.Task.ID, nil)
|
_, err := rpcServer.Call(ctx, w.Conn, "task-delete", ts.Task.ID, nil)
|
||||||
|
@ -220,8 +235,6 @@ func updateWorkerTaskStatus(ctx context.Context) {
|
||||||
slog.ErrorContext(ctx, "Error Deleting Finished Task From Worker", "err", err)
|
slog.ErrorContext(ctx, "Error Deleting Finished Task From Worker", "err", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Update file health for healthcheck tasks
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}()
|
}()
|
||||||
|
|
Loading…
Add table
Reference in a new issue