would you mind elaborating on this? I did get it work doing the following but not sure if that’s a “good” way:
index.ts
`register({ strapi }) {
strapi.log.debug(“
Setting up structured-listing-worker …”);
setUpStructuredListingWorker(strapi);
},`
src/workers/listingWorker.ts
`import { Strapi } from “@strapi/strapi”;
import { Job, Worker } from “bullmq”;
import structuredListingJob from “./structuredListingJob”;
let worker: Worker;
export function setUpStructuredListingWorker(strapi: Strapi): void {
worker = new Worker(
“structured-listing-queue”,
async (job: Job) => {
// Do something with job
return structuredListingJob(job, strapi);
},
{
connection: strapi.config.get(“queue.redisQueue”),
concurrency: 1,
useWorkerThreads: true,
}
);
worker.on(“completed”, (job) => {
console.log(
“
Structured Listing Worker | Job ${job.id} completed successfully.”
);
});`
So essentially I am passing the Strapi instance down all the way from the register function. Does that seem a good way to do it? I’m glad this is at least working but ultimately, my idea to have it run on a seperate thread was to give my CPU some space for webservice tasks while my worker does some heavy long-time taking AI processing in the background.