Skip to content

PM2 deployment

Use this guide when you want to run the Blurt MCP server as a long-lived Node.js process on a VPS or plain Linux host. PM2 manages the process lifecycle; the server still expects TLS, public rate limits, request body limits and host routing to live in a reverse proxy such as Caddy, nginx, a CDN or your hosting platform.

PM2 is a good choice when you want:

  • a small Node.js process manager with restart and boot integration;
  • simple log streaming with pm2 logs and pm2 monit;
  • deployment from a normal source checkout.

Configuration model

The PM2 ecosystem file is intentionally not the runtime configuration source. It exposes only BLURT_ENV_FILE, and the server loads all application settings from that file.

Repository example:

text
ecosystem.config.cjs

Runtime configuration file used by the example:

text
/home/you/.config/blurt-mcp/secret.env

Create the directory and environment file on the host:

bash
mkdir -p /home/you/.config/blurt-mcp
chmod 700 /home/you/.config/blurt-mcp
$EDITOR /home/you/.config/blurt-mcp/secret.env
chmod 600 /home/you/.config/blurt-mcp/secret.env

Minimal public HTTP configuration:

dotenv
NODE_ENV=production
LOG_LEVEL=info
HOST=127.0.0.1
PORT=3000
BLURT_HTTP_JSON_BODY_LIMIT=256kb
BLURT_RPC_URLS=https://rpc.beblurt.com,https://rpc.blurt.world
BLURT_PRICE_URL=https://api.blurt.blog/price_info

Keep BLURT_POSTING_KEY out of public HTTP deployments. If you need signing, use local stdio or a private trusted deployment with explicit external controls.

Install and build

From the checkout:

bash
npm ci
npm run build
npm install -g pm2

Review the BLURT_ENV_FILE path in ecosystem.config.cjs before starting the service.

First start

bash
pm2 start ecosystem.config.cjs
pm2 status blurt-mcp-server

Then configure the reverse proxy to send /mcp, /healthz and /readyz to the local process, for example 127.0.0.1:3000 when using the environment file above.

Validate the process and endpoint:

bash
curl http://127.0.0.1:3000/healthz
curl http://127.0.0.1:3000/readyz
MCP_URL=https://mcp.example.org/mcp npm run smoke:http

Reload vs restart

Use reload for normal deployments after changing code or environment configuration:

bash
git pull --ff-only
npm ci
npm run build
pm2 reload blurt-mcp-server --update-env
npm run smoke:http

Use restart when you explicitly want a full stop/start cycle or when troubleshooting a stuck process:

bash
pm2 restart blurt-mcp-server --update-env

--update-env matters when BLURT_ENV_FILE itself changes in the PM2 process environment. Changes inside the referenced secret.env are picked up by the next process start because the server loads that file at startup.

Logs and monitoring

Stream logs:

bash
pm2 logs blurt-mcp-server

Show recent lines only:

bash
pm2 logs blurt-mcp-server --lines 100

Open PM2's terminal monitor:

bash
pm2 monit

In production, the Blurt MCP logger writes JSON lines to stderr with its own timestamp. The PM2 example therefore does not add PM2 timestamp formatting or custom output files. Use OS log rotation or pm2-logrotate for long-lived hosts.

Save and startup

After the process list is correct:

bash
pm2 save
pm2 startup

pm2 startup prints a platform-specific command. Run that command if you want PM2 to restore saved processes after a reboot.

Stop or remove

Stop without deleting the PM2 process definition:

bash
pm2 stop blurt-mcp-server

Remove it from PM2 entirely:

bash
pm2 delete blurt-mcp-server

If you delete the process and want the saved boot state to match, run:

bash
pm2 save

Ecosystem options used

OptionValueWhy it is used
scriptdist/server.jsRuns the compiled HTTP entrypoint. Build before starting PM2.
cwd__dirnameMakes script and fallback .env resolution independent of the shell directory.
exec_mode / instancesfork / 1Avoids premature local clustering; scale at the reverse proxy/platform after measuring real traffic.
autorestarttrueMakes the process manager restart the server after crashes.
watchfalseKeeps production deployments from restarting on generated file or log changes.
max_restarts / min_uptime10 / 10sLimits rapid crash loops caused by bad builds or invalid configuration.
kill_timeout5000Gives Node a short grace period during restarts.
env.BLURT_ENV_FILE/home/you/.config/blurt-mcp/secret.envPoints the server at the single runtime configuration file.

Options intentionally omitted

OptionWhy it is omitted
interpreterPM2 already uses Node for .js scripts.
time / log_date_formatProduction logs already contain JSON timestamps from the application logger.
out_file / error_fileLog paths and rotation are host policy; PM2 defaults plus log rotation are sufficient for the example.
merge_logsUseful mainly with multiple instances or cluster mode; this example runs one process.
restart_delaymax_restarts and min_uptime already cover crash loops without adding another timing policy.
max_memory_restartMemory limits are host- and traffic-specific. Add one after observing baseline memory usage.

For advanced PM2 behavior, see the PM2 documentation for ecosystem files, restart strategies and log management.