📄 SKILL.md

← Vault

name: documentos-vps-restore

description: Restore DocCorretor app on VPS when it's down (502/500) — fix port 3010 zombie process

category: devops


DocCorretor Production Restore

Diagnosis

`bash

ss -tlnp | grep 3010

lsof -i :3010

curl -s -o /dev/null -w "%{http_code}" https://documentos.rochasalesseguros.com.br

`

Root Cause

Port 3010 occupied by zombie start-server.mjs node process.

Restore Steps

1. Kill zombie:

`bash

lsof -i :3010 # get PID

kill -9

`

2. Start via systemd:

`bash

sudo systemctl start documentos

curl -s -o /dev/null -w "%{http_code}" https://documentos.rochasalesseguros.com.br

`

If systemd not configured:

`bash

cd /var/www/documentos2/app

/root/.nvm/versions/node/v20.20.2/bin/node start-server.mjs &

`

After code changes — rebuild + restart:

`bash

cd /var/www/documentos2/app

rm -rf dist .tanstack node_modules/.vite .vite

PATH="/root/.nvm/versions/node/v20.20.2/bin:$PATH" npm run build

mkdir -p dist/client/assets

cp -r dist/server/assets/* dist/client/assets/

sudo systemctl restart documentos

`

Critical: Zombie Process on Port 3010

systemctl restart spawns a NEW process but an OLD zombie node process may still hold port 3010.

Nginx proxies to the old process first — page stays frozen on old code.

Diagnosis:

`bash

lsof -i :3010 # shows ALL processes on port (old AND new)

ps aux | grep start-server # check PIDs and START times

`

Fix: Kill the zombie by PID (NOT just restart):

`bash

Get the zombie PID (oldest one, check START column)

lsof -i :3010

Kill it specifically

kill -9

Now the good process takes over

sudo systemctl restart documentos

`

Example: If lsof shows PIDs 2576 and 3965514, and ps shows PID 2576 started May 26 while 3965514 started today → kill 2576.

Key Paths