fix: don't cancel schedule deployments running outside the panel process on restart (#5053)

Fixes #4986. initCancelDeployments blindly marked every 'running'
deployment as 'cancelled' on boot, including schedule runs whose
actual work (docker exec into another container, or SSH to a remote
host) is decoupled from the Dokploy process and keeps running after
a restart. Now only deployments with no schedule, or schedules of
type dokploy-server (a real child process), get cancelled.

Also resolve any stale 'running' deployment for a schedule when a
new run starts, so restarted panels don't leave ghost 'running' rows
forever.
This commit is contained in:
Mauricio Siu
2026-08-11 21:33:49 -06:00
committed by GitHub
parent 3cad115155
commit f12ecc3350
2 changed files with 43 additions and 3 deletions
@@ -453,6 +453,19 @@ export const createDeploymentSchedule = async (
schedule.compose?.serverId ||
schedule.server?.serverId;
await removeLastTenDeployments(deployment.scheduleId, "schedule", serverId);
await db
.update(deployments)
.set({
status: "error",
errorMessage: "Superseded by a new run of this schedule.",
finishedAt: new Date().toISOString(),
})
.where(
and(
eq(deployments.scheduleId, deployment.scheduleId),
eq(deployments.status, "running"),
),
);
try {
const { SCHEDULES_PATH } = paths(!!serverId);
const formattedDateTime = format(new Date(), "yyyy-MM-dd:HH:mm:ss");