fix: a crawl cancel waits for its job, and a stale crawl is ended
Cancelling a running crawl records cancel_requested_at and leaves the row running until its job stops and writes cancelled, so no second crawl starts and the row cannot be deleted or pruned meanwhile. The job writes heartbeat_at every minute; a running crawl without a heartbeat for 10 minutes is ended by the next start or delete.
This commit is contained in:
@@ -81,7 +81,7 @@ func (c crawlsAdminController) AdminRecordActions() []pact.AdminRecordAction {
|
||||
Permissions: []string{PermissionManage},
|
||||
Applies: func(_ context.Context, record any) (bool, error) {
|
||||
row, ok := record.(*models.Crawl)
|
||||
return ok && row != nil && row.Active(), nil
|
||||
return ok && row != nil && row.Active() && !row.Cancelling(), nil
|
||||
},
|
||||
Run: func(ctx context.Context, in pact.AdminRecordActionInput) (pact.AdminRecordActionResult, error) {
|
||||
row, ok := in.Record.(*models.Crawl)
|
||||
@@ -194,7 +194,9 @@ func (c crawlsAdminController) ListExtendRecords(ctx context.Context, db *gorm.D
|
||||
row.IssuesCell = strconv.Itoa(counts[row.ID])
|
||||
row.DurationCell = Duration(*row)
|
||||
row.TriggerCell = TriggerLabel(ctx, svc, *row)
|
||||
if key, ok := statusKeys[row.Status]; ok {
|
||||
if row.Cancelling() {
|
||||
row.Status = svc.PhraseCtx(ctx, "golem15.seo::lang.crawls.st_cancelling", nil)
|
||||
} else if key, ok := statusKeys[row.Status]; ok {
|
||||
row.Status = svc.PhraseCtx(ctx, key, nil)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user