Bullstudio
Embedded

Fastify

Mount Bullstudio as a Fastify plugin.

Install

pnpm add @bullstudio/fastify @bullstudio/bullmq-adapter bullmq ioredis fastify

Mount the dashboard

import { createBullMqQueueAdapter } from "@bullstudio/bullmq-adapter";
import { bullstudio } from "@bullstudio/fastify";
import { Queue } from "bullmq";
import Fastify from "fastify";
import IORedis from "ioredis";

const connection = new IORedis(process.env.REDIS_URL!, {
  maxRetriesPerRequest: null,
});

const emailQueue = new Queue("email", { connection });
const app = Fastify();

await app.register(
  bullstudio({
    queues: [
      createBullMqQueueAdapter(emailQueue, {
        key: "email",
        label: "Email",
      }),
    ],
    protection: {
      type: "session",
      username: process.env.BULLSTUDIO_USERNAME ?? "operator",
      password: process.env.BULLSTUDIO_PASSWORD!,
      sessionSecret: process.env.BULLSTUDIO_SESSION_SECRET!,
    },
  }),
  {
    prefix: "/ops/bullstudio",
  },
);

await app.listen({ port: 3000 });

Open http://localhost:3000/ops/bullstudio.

Shutdown

Bullstudio does not close host-owned queues or Redis connections.

async function shutdown() {
  await app.close();
  await emailQueue.close();
  await connection.quit();
}

On this page