mirror of
https://github.com/hansjone/dsh-ops-cron.git
synced 2026-10-09 00:43:22 +08:00
Preserve run start timestamps when settling terminal status.
cron_runs entered/exited were identical because settleRun rewrote stateEnteredAt and actualAt to the finish instant. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
6ed7187754
commit
8cc3bed5f1
2 changed files with 37 additions and 7 deletions
11
lib/fire.js
11
lib/fire.js
|
|
@ -252,13 +252,14 @@ export function settleRun(state, runId, terminal, now) {
|
|||
const status = terminal?.status && !ACTIVE_RUN_STATUSES.has(terminal.status)
|
||||
? terminal.status
|
||||
: 'succeeded'
|
||||
const prevStatus = run.status
|
||||
// Keep stateEnteredAt / actualAt from queued→running so cron_runs duration is real.
|
||||
// Only stamp exitedAt (and lastRunAt on the job) at settle time.
|
||||
let next = patchRun(state, runId, {
|
||||
status,
|
||||
summary: terminal?.summary || '',
|
||||
error: terminal?.error || null,
|
||||
actualAt: now,
|
||||
stateEnteredAt: prevStatus === status ? (run.stateEnteredAt || now) : now,
|
||||
actualAt: run.actualAt || now,
|
||||
stateEnteredAt: run.stateEnteredAt || run.actualAt || now,
|
||||
exitedAt: now,
|
||||
sessionId: run.sessionId,
|
||||
...terminal?.outputRef ? { outputRef: terminal.outputRef } : {},
|
||||
|
|
@ -389,8 +390,8 @@ export function interruptActiveRuns(state, now, reason = 'host_interrupted') {
|
|||
status: 'failed',
|
||||
error: reason,
|
||||
summary: 'Host stopped before this run finished',
|
||||
actualAt: now,
|
||||
stateEnteredAt: now,
|
||||
actualAt: run.actualAt || now,
|
||||
stateEnteredAt: run.stateEnteredAt || run.actualAt || now,
|
||||
exitedAt: now,
|
||||
})
|
||||
const job = getJob(next, run.jobId)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue