Implement Queue Health On New File and Queue Transcode on Health Success
All checks were successful
/ release (push) Successful in 32s
All checks were successful
/ release (push) Successful in 32s
This commit is contained in:
parent
f08a07e87d
commit
12f700d1d0
7 changed files with 60 additions and 24 deletions
|
@ -247,7 +247,8 @@ func updateWorkerTaskStatus(ctx context.Context) {
|
|||
var health constants.FileHealth
|
||||
if ts.Task.Status == constants.TASK_STATUS_SUCCESS {
|
||||
health = constants.FILE_HEALTH_HEALTHY
|
||||
// TODO Auto Queue Transcode for Successfull Transcodes if library setting
|
||||
// Auto Queue Transcode for Successfull Transcodes if library setting say so
|
||||
go queueOnHealth(context.TODO(), ts.Task.ID)
|
||||
} 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
|
||||
|
@ -294,3 +295,26 @@ func updateWorkerTaskStatus(ctx context.Context) {
|
|||
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func queueOnHealth(ctx context.Context, taskID int) {
|
||||
var transcode_command_id *int
|
||||
var file_id *int
|
||||
err := db.QueryRow(ctx, `SELECT libraries.transcode_command_id, file.id
|
||||
FROM tasks
|
||||
INNER JOIN files ON files.id = tasks.file_id
|
||||
INNER JOIN libraries ON files.library_id = libraries.id
|
||||
WHERE tasks.id = $1 AND libraries.health_ok_queue_transcode = t AND libraries.transcode_command_id IS NOT NULL`, taskID).
|
||||
Scan(&transcode_command_id, &file_id)
|
||||
if err == pgx.ErrNoRows {
|
||||
slog.DebugContext(ctx, "No need to queue Transcode", "task_id", taskID)
|
||||
} else if err != nil {
|
||||
slog.ErrorContext(ctx, "Unable to Query if and how she should queue a Transcode on Health Check Success", "err", err)
|
||||
return
|
||||
}
|
||||
|
||||
slog.InfoContext(ctx, "Queueing Transcode On HealthCheck Success", "health_task_id", taskID, "transcode_command_id", transcode_command_id)
|
||||
_, err = db.Exec(ctx, "INSERT INTO tasks (file_id, type, status, data, ffmpeg_command_id) VALUES ($1,$2,$3,$4,$5)", file_id, constants.TASK_TYPE_TRANSCODE, constants.TASK_STATUS_QUEUED, nil, transcode_command_id)
|
||||
if err != nil {
|
||||
slog.ErrorContext(ctx, "Queueing Transcode On HealthCheck Success", "err", err, "health_task_id", taskID, "transcode_command_id", transcode_command_id)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue