# Reboot Handoff — 2026-04-15

**Status when handoff written:** OS updates applied, awaiting reboot.

## What just happened (this session)

1. **Investigated & restarted a hung Next.js process** (169-day uptime, stuck event loop) → working again
2. **Hardened PM2 config** in `ecosystem.config.js`: added `min_uptime`, `max_restarts`, `restart_delay`, `cron_restart: '0 4 * * 0'` (weekly Sunday 4 AM recycle)
3. **Killed Prisma Studio** — was running long-term on `0.0.0.0:5555` with no auth (security risk). Not PM2-managed, won't respawn.
4. **Decommissioned legacy parallel install** at `/home/acstrat1/lovisamedia.com/`:
   - Removed 2 cron entries (`@reboot pm2 start` and `*/2 * * * * monitor-services.sh`)
   - Deleted acstrat1 PM2 apps (`api`, `dashboard`) and killed the daemon
   - Archive: `/home/mahlinacstrat/backups/acstrat1_lovisamedia_legacy_20260414.tar.gz` (316 MB)
   - Directory removed (freed 2.2 GB)
5. **Project cleanup:** removed `api/node_modulesbak/` (58 MB) and 11 stray pre-migration `.html` files.
   - Archive: `/home/mahlinacstrat/backups/legacy_html_and_modulesbak_20260414.tar.gz`
6. **Refactored landing page** to load copy from JSON at request time:
   - `content/landing.json` (source of truth)
   - `lib/content.ts` (typed loader)
   - `components/LandingPage.tsx` (client component)
   - `app/page.tsx` (server component, `export const dynamic = 'force-dynamic'`)
   - Edits to JSON now live on next page load — no rebuild needed
7. **Tier 1 updates:** `npm update` (150+ patch/minor bumps, 0 vulns), rebuilt, PM2 reloaded. Site serving HTTP 200.
8. **Tier 2 updates:** `dnf update --security -y` (390 advisories applied) + `dnf update -y --nobest` (rest applied, only `libc-client` skipped due to repo conflict with wp-toolkit-thirdparties). New kernel installed: `5.14.0-611.45.1.el9_7`. Moved from AlmaLinux 9.6 → 9.7.

## ⏭ What to do after reboot

### 1. Verify services came back up
```bash
# PM2 apps should auto-start (pm2-root.service)
/root/.n/lib/node_modules/pm2/bin/pm2 list
# Expect: lovisa-nextjs (port 3000, fork) + lovisa-api (port 3001, cluster x2), all online

# Nginx and Apache
systemctl status nginx httpd --no-pager | head -20

# Database
systemctl status postgresql --no-pager | head -10
```

### 2. Verify endpoints
```bash
curl -sS -o /dev/null -w "Site: HTTP %{http_code}\n" https://lovisamedia.com/
curl -sS -o /dev/null -w "API:  HTTP %{http_code}\n" http://127.0.0.1:3001/api/health
```

### 3. Confirm kernel
```bash
uname -r
# Expected: 5.14.0-611.45.1.el9_7.x86_64 (was 5.14.0-570.33.2.el9_6 before reboot)
cat /etc/almalinux-release
# Expected: AlmaLinux release 9.7 (or 9.6+ — the el9_7 packages came in)
```

### 4. If PM2 apps didn't auto-start
```bash
cd /home/mahlinacstrat/lovisamedia.com
/root/.n/lib/node_modules/pm2/bin/pm2 resurrect
# Or:
/root/.n/lib/node_modules/pm2/bin/pm2 start ecosystem.config.js
/root/.n/lib/node_modules/pm2/bin/pm2 save
```

### 5. If site is down but PM2 shows online
- Next.js hung (same issue as before — check uptime, restart if needed):
  `/root/.n/lib/node_modules/pm2/bin/pm2 restart lovisa-nextjs`
- Apache proxy missing: check `/etc/apache2/conf.d/userdata/ssl/2_4/mahlinacstrat/lovisamedia.com/nextjs_proxy.conf` still exists
- If not: `/usr/local/cpanel/scripts/rebuildhttpdconf && /usr/local/cpanel/scripts/restartsrv_httpd`

## 🚫 Not done yet (Tier 3 — major version bumps, needs separate planning)
- Next.js 15 → 16 (breaking)
- Prisma 6 → 7 (breaking)
- Tailwind 3 → 4 (breaking)
- TypeScript 5 → 6
- ESLint 9 → 10

## Key paths
- Project root: `/home/mahlinacstrat/lovisamedia.com`
- PM2 binary: `/root/.n/lib/node_modules/pm2/bin/pm2` (not on root `$PATH`)
- Backups: `/home/mahlinacstrat/backups/`
- Apache proxy include: `/etc/apache2/conf.d/userdata/ssl/2_4/mahlinacstrat/lovisamedia.com/nextjs_proxy.conf`

## Known issue
- One `libc-client` update skipped due to `wp-toolkit-thirdparties` repo conflict. Not critical — mail still works. Can be resolved later with `dnf update --allowerasing libc-client uw-imap-devel` (will uninstall uw-imap-devel, only needed if you're building against UW IMAP libs).
