# Running with PM2

> Run Foundry as a daemon so it survives terminal close and restarts on crash.

Source: https://bifrost5.com/foundry/docs/pm2/

# PM2 Integration

Information

Run this for a team without carrying every upgrade alone, since Production-Grade comes with engineering support.

[See editions](/foundry/docs/editions)

Run Foundry as a daemon so it survives terminal close and restarts on crash.

## Start

```
pm2 start pnpm --name supervisor -- run cli -- start --redis-host localhost --redis-port 6499 --state-key supervisor:state --queue-name tasks --queue-db 2
```

(Use `npm` instead of `pnpm` if you use npm.)

## Logs and Control

- **Logs**: `pm2 logs supervisor` or `pm2 logs supervisor --nostream` for history

- **Status**: `pm2 list`

- **Stop**: `pm2 stop supervisor`

- **Restart**: `pm2 restart supervisor`

- **Remove**: `pm2 delete supervisor`

## Ecosystem File

You can define the app in `ecosystem.config.cjs` and run `pm2 start ecosystem.config.cjs`. Set `script` to `pnpm` or `npm`, `args` to the `run cli -- start ...` arguments, and `cwd` to the project root.
