A template for deploying a BullMQ and Redis queueing system.
This application uses BullMQ, a Redis-based queueing system, and Bull-Board, a dashboard to monitor and manage these queues, served by a Fastify server. Both services are built using Rslib and managed by PM2.
There are three distinct ways to start the services:
Unified Execution: To start both services simultaneously, use the command pnpm start. This is the simplest option for local development.
Separate Execution: To start the worker and Fastify server individually, use the commands pnpm start:worker and pnpm start:server, respectively. This approach offers greater control and is used in the Railway template, but can be easily adapted to your needs.
Direct Node.js Execution: For simple projects that do not require PM2 features, direct execution with Node.js can result in lower resource consumption. Use node ./dist/worker.js for the worker and node ./dist/server.js for the Fastify server.
PM2 also supports Bun. If desired, you can replace the project's package manager with Bun and execute the TypeScript files directly (Bun has native support for TypeScript), eliminating the need for a build. However, be aware that Bun is not fully compatible with Node.js, which may result in execution problems.
Scalability (PM2): Both services support horizontal scaling through the WORKER_INSTANCES and SERVER_INSTANCES environment variables. Set these variables to the desired number of instances to increase the processing capacity of the worker and server, respectively. These variables will only take effect if PM2 is being used.
You need to have the following main dependency installed:
Do you use nvm? Then you can run nvm install in the project folder to install and use the most appropriate version of Node.js.
After cloning the repository, install the project's local dependencies:
pnpm installCreate a .env file similar to .env.example.
# Redis
REDIS_HOST="localhost"
REDIS_PORT=6379
REDIS_USER=""
REDIS_PASSWORD=""To run the project locally, just run the command below:
pnpm devThis project is licensed under the MIT License - see the LICENSE file for details