This commit is contained in:
parent
77d7a8624c
commit
b03e85db0b
7 changed files with 77 additions and 2 deletions
|
@ -371,8 +371,18 @@ func assignQueuedTasks(ctx context.Context) error {
|
|||
return nil
|
||||
}
|
||||
if Workers[i].Connected {
|
||||
var queueEnable bool
|
||||
err := db.QueryRow(ctx, "SELECT queue_enable FROM workers WHERE id = $1", i).Scan(&queueEnable)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error Querying Worker Queue Enable: %w", err)
|
||||
}
|
||||
if !queueEnable {
|
||||
slog.DebugContext(ctx, "Skipping Worker since Queueing is disabled", "worker_id", i)
|
||||
continue
|
||||
}
|
||||
|
||||
var count int
|
||||
err := db.QueryRow(ctx, "SELECT COUNT(*) FROM tasks WHERE worker_id = $1 AND (status = $2 OR status = $3 OR status = $4 OR status = $5)", i, constants.TASK_STATUS_UNKNOWN, constants.TASK_STATUS_ASSIGNED, constants.TASK_STATUS_RUNNING, constants.TASK_STATUS_WAITING).Scan(&count)
|
||||
err = db.QueryRow(ctx, "SELECT COUNT(*) FROM tasks WHERE worker_id = $1 AND (status = $2 OR status = $3 OR status = $4 OR status = $5)", i, constants.TASK_STATUS_UNKNOWN, constants.TASK_STATUS_ASSIGNED, constants.TASK_STATUS_RUNNING, constants.TASK_STATUS_WAITING).Scan(&count)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error Querying Worker Task Count: %w", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue