bun-cluster-reload
v0.0.2
Published
PM2-like cluster with reload for bun
Downloads
7
Readme
bun-cluster-reload
pm2-like cluster with reload for bun
Installation
bun add bun-cluster-reload
Features
- Auto-restart on error
- PM2-like reload on signal
- PM2-like waitReady option
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
notpm2
. So you'll see a single process in pm2 monitoring
- Note that the clustering happens in
- To reload, send predefined signal to process using
pm2 send signal
. For example:pm2 sendSignal SIGHUP app