-
Notifications
You must be signed in to change notification settings - Fork 6
Description
The Goal is to execute the Admin verify links job on a separate Heroku dyno.
- The VerifyLinksJob must extend the new Job abstract class.
- Add the VerifyLinksJob in the folder src/server/worker/tasks
- The proc file should include the new dyno
- The job must still run in a queue (no separate thread) one at the time
task-verifyLinks: node dist/server/worker/tasks/verifyLinks.js
- The endpoint to exec the Job should be like: (use axios and ProcessEnv instead)
if (process.env.LOCAL === "true") {
console.log("Running task locally...");
require("./pathToJs")();
return;
}
const url = `https://api.heroku.com/apps/${process.env.HEROKU_APP_NAME}/dynos`;
const payload = {
command: "node dist/server/worker/tasks/verifyLinks.js",
type: "run",
};
const res = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/vnd.heroku+json; version=3",
Authorization: `Bearer ${process.env.HEROKU_API_KEY}`,
},
body: JSON.stringify(payload),
});
if (!res.ok) {
console.log("Heroku API Error:", await res.text());
throw new Error("Failed to trigger job");
}
console.log("Success:", await res.json());- to get job status (stored in redis), implement job.getStatus() method. and the endpoint will contain the following code
new VerifyLinksJob().getStatus()
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request