Skip to content

nxht/bun-cluster-reload

Repository files navigation

bun-cluster-reload

pm2-like cluster with reload for bun

Installation

bun add bun-cluster-reload

Features

Example

import { ClusterRunner } from 'bun-cluster-reload';

const clusterRunner = new ClusterRunner({
  numCPUs: 2,
  logger: console,
  autorestart: true,
  waitReady: true,
});

await clusterRunner.start({
  command: ['bun', 'src/index.ts'],
  reloadSignal: 'SIGHUP',
  updateEnv: false,
});

Using with PM2

  • Set bun as pm2 interpreter as in official Bun guide
  • The target script should be the ClusterRunner file
    • Note that the clustering happens in bun not pm2. So you'll see a single process in pm2 monitoring
  • To reload, send predefined signal to process using pm2 send signal. For example:
    pm2 sendSignal SIGHUP app

About

PM2-like cluster with reload for bun

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published