mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-06 06:25:28 +02:00
Add jobId to deployment flow for tracking deployments
Co-authored-by: Siumauricio <47042324+Siumauricio@users.noreply.github.com>
This commit is contained in:
@@ -325,6 +325,7 @@ export const applicationRouter = createTRPCRouter({
|
||||
message: "You are not authorized to redeploy this application",
|
||||
});
|
||||
}
|
||||
const jobId = nanoid();
|
||||
const jobData: DeploymentJob = {
|
||||
applicationId: input.applicationId,
|
||||
titleLog: input.title || "Rebuild deployment",
|
||||
@@ -332,6 +333,7 @@ export const applicationRouter = createTRPCRouter({
|
||||
type: "redeploy",
|
||||
applicationType: "application",
|
||||
server: !!application.serverId,
|
||||
jobId,
|
||||
};
|
||||
|
||||
if (IS_CLOUD && application.serverId) {
|
||||
@@ -339,7 +341,7 @@ export const applicationRouter = createTRPCRouter({
|
||||
deploy(jobData).catch((error) => {
|
||||
console.error("Background deployment failed:", error);
|
||||
});
|
||||
return true;
|
||||
return { jobId };
|
||||
}
|
||||
await myQueue.add(
|
||||
"deployments",
|
||||
@@ -349,6 +351,7 @@ export const applicationRouter = createTRPCRouter({
|
||||
removeOnFail: true,
|
||||
},
|
||||
);
|
||||
return { jobId };
|
||||
}),
|
||||
saveEnvironment: protectedProcedure
|
||||
.input(apiSaveEnvironmentVariables)
|
||||
@@ -693,6 +696,7 @@ export const applicationRouter = createTRPCRouter({
|
||||
message: "You are not authorized to deploy this application",
|
||||
});
|
||||
}
|
||||
const jobId = nanoid();
|
||||
const jobData: DeploymentJob = {
|
||||
applicationId: input.applicationId,
|
||||
titleLog: input.title || "Manual deployment",
|
||||
@@ -700,6 +704,7 @@ export const applicationRouter = createTRPCRouter({
|
||||
type: "deploy",
|
||||
applicationType: "application",
|
||||
server: !!application.serverId,
|
||||
jobId,
|
||||
};
|
||||
if (IS_CLOUD && application.serverId) {
|
||||
jobData.serverId = application.serverId;
|
||||
@@ -707,7 +712,7 @@ export const applicationRouter = createTRPCRouter({
|
||||
console.error("Background deployment failed:", error);
|
||||
});
|
||||
|
||||
return true;
|
||||
return { jobId };
|
||||
}
|
||||
await myQueue.add(
|
||||
"deployments",
|
||||
@@ -717,6 +722,7 @@ export const applicationRouter = createTRPCRouter({
|
||||
removeOnFail: true,
|
||||
},
|
||||
);
|
||||
return { jobId };
|
||||
}),
|
||||
|
||||
cleanQueues: protectedProcedure
|
||||
|
||||
@@ -406,6 +406,7 @@ export const composeRouter = createTRPCRouter({
|
||||
message: "You are not authorized to deploy this compose",
|
||||
});
|
||||
}
|
||||
const jobId = nanoid();
|
||||
const jobData: DeploymentJob = {
|
||||
composeId: input.composeId,
|
||||
titleLog: input.title || "Manual deployment",
|
||||
@@ -413,6 +414,7 @@ export const composeRouter = createTRPCRouter({
|
||||
applicationType: "compose",
|
||||
descriptionLog: input.description || "",
|
||||
server: !!compose.serverId,
|
||||
jobId,
|
||||
};
|
||||
|
||||
if (IS_CLOUD && compose.serverId) {
|
||||
@@ -420,7 +422,7 @@ export const composeRouter = createTRPCRouter({
|
||||
deploy(jobData).catch((error) => {
|
||||
console.error("Background deployment failed:", error);
|
||||
});
|
||||
return true;
|
||||
return { jobId };
|
||||
}
|
||||
await myQueue.add(
|
||||
"deployments",
|
||||
@@ -430,7 +432,7 @@ export const composeRouter = createTRPCRouter({
|
||||
removeOnFail: true,
|
||||
},
|
||||
);
|
||||
return { success: true, message: "Deployment queued" };
|
||||
return { jobId };
|
||||
}),
|
||||
redeploy: protectedProcedure
|
||||
.input(apiRedeployCompose)
|
||||
@@ -445,6 +447,7 @@ export const composeRouter = createTRPCRouter({
|
||||
message: "You are not authorized to redeploy this compose",
|
||||
});
|
||||
}
|
||||
const jobId = nanoid();
|
||||
const jobData: DeploymentJob = {
|
||||
composeId: input.composeId,
|
||||
titleLog: input.title || "Rebuild deployment",
|
||||
@@ -452,13 +455,14 @@ export const composeRouter = createTRPCRouter({
|
||||
applicationType: "compose",
|
||||
descriptionLog: input.description || "",
|
||||
server: !!compose.serverId,
|
||||
jobId,
|
||||
};
|
||||
if (IS_CLOUD && compose.serverId) {
|
||||
jobData.serverId = compose.serverId;
|
||||
deploy(jobData).catch((error) => {
|
||||
console.error("Background deployment failed:", error);
|
||||
});
|
||||
return true;
|
||||
return { jobId };
|
||||
}
|
||||
await myQueue.add(
|
||||
"deployments",
|
||||
@@ -468,7 +472,7 @@ export const composeRouter = createTRPCRouter({
|
||||
removeOnFail: true,
|
||||
},
|
||||
);
|
||||
return { success: true, message: "Redeployment queued" };
|
||||
return { jobId };
|
||||
}),
|
||||
stop: protectedProcedure
|
||||
.input(apiFindCompose)
|
||||
|
||||
@@ -24,12 +24,14 @@ export const deploymentWorker = new Worker(
|
||||
applicationId: job.data.applicationId,
|
||||
titleLog: job.data.titleLog,
|
||||
descriptionLog: job.data.descriptionLog,
|
||||
jobId: job.data.jobId,
|
||||
});
|
||||
} else if (job.data.type === "deploy") {
|
||||
await deployApplication({
|
||||
applicationId: job.data.applicationId,
|
||||
titleLog: job.data.titleLog,
|
||||
descriptionLog: job.data.descriptionLog,
|
||||
jobId: job.data.jobId,
|
||||
});
|
||||
}
|
||||
} else if (job.data.applicationType === "compose") {
|
||||
@@ -41,12 +43,14 @@ export const deploymentWorker = new Worker(
|
||||
composeId: job.data.composeId,
|
||||
titleLog: job.data.titleLog,
|
||||
descriptionLog: job.data.descriptionLog,
|
||||
jobId: job.data.jobId,
|
||||
});
|
||||
} else if (job.data.type === "redeploy") {
|
||||
await rebuildCompose({
|
||||
composeId: job.data.composeId,
|
||||
titleLog: job.data.titleLog,
|
||||
descriptionLog: job.data.descriptionLog,
|
||||
jobId: job.data.jobId,
|
||||
});
|
||||
}
|
||||
} else if (job.data.applicationType === "application-preview") {
|
||||
@@ -60,6 +64,7 @@ export const deploymentWorker = new Worker(
|
||||
titleLog: job.data.titleLog,
|
||||
descriptionLog: job.data.descriptionLog,
|
||||
previewDeploymentId: job.data.previewDeploymentId,
|
||||
jobId: job.data.jobId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ type DeployJob =
|
||||
type: "deploy" | "redeploy";
|
||||
applicationType: "application";
|
||||
serverId?: string;
|
||||
jobId?: string;
|
||||
}
|
||||
| {
|
||||
composeId: string;
|
||||
@@ -16,6 +17,7 @@ type DeployJob =
|
||||
type: "deploy" | "redeploy";
|
||||
applicationType: "compose";
|
||||
serverId?: string;
|
||||
jobId?: string;
|
||||
}
|
||||
| {
|
||||
applicationId: string;
|
||||
@@ -26,6 +28,7 @@ type DeployJob =
|
||||
applicationType: "application-preview";
|
||||
previewDeploymentId: string;
|
||||
serverId?: string;
|
||||
jobId?: string;
|
||||
};
|
||||
|
||||
export type DeploymentJob = DeployJob;
|
||||
|
||||
Reference in New Issue
Block a user