docs: CHANGELOG v2.0.3 — PortManager + crash-loop fix
This commit is contained in:
45
CHANGELOG.md
45
CHANGELOG.md
@@ -7,6 +7,51 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## [2.0.3] - 2026-05-06
|
||||||
|
|
||||||
|
### 🏗️ Architecture
|
||||||
|
|
||||||
|
#### PortManager — Intelligent Port Lifecycle Manager
|
||||||
|
|
||||||
|
Replaced 158 lines of fragile inline port logic with a proper stateful module (`src/bot/port-manager.js`). The old approach (`probePort` → `killStaleProcess` → `waitForPort` → `bindPort` → `process.exit(1)`) caused crash-loops under systemd due to race conditions between rapid restarts.
|
||||||
|
|
||||||
|
**PortManager features:**
|
||||||
|
- State machine: `idle` → `probing` → `claiming` → `owned` → `releasing` → `failed`
|
||||||
|
- Triple holder detection: pidfile → `ss -tlnp` → `lsof` fallback
|
||||||
|
- Age-based kill strategy (young sibling processes get waited on, not killed)
|
||||||
|
- Exponential backoff retry (5 attempts, 500ms → 5000ms) instead of instant `process.exit(1)`
|
||||||
|
- EventEmitter for `stateChange`, `claimed`, `retry`, `failed` events
|
||||||
|
- `getStatus()` for diagnostics and health checks
|
||||||
|
- Exposed in bot return object alongside pluginManager, swarm, hooks
|
||||||
|
|
||||||
|
**All previous features preserved — zero downgrades:**
|
||||||
|
| Old function | New location | Status |
|
||||||
|
|---|---|---|
|
||||||
|
| `acquirePidfile()` | `#writePidfile()` | ✅ |
|
||||||
|
| `releasePidfile()` | `release()` | ✅ |
|
||||||
|
| `readStalePid()` | `#identifyHolder()` (method 1) | ✅ |
|
||||||
|
| `isProcessAlive()` | `#isAlive()` | ✅ |
|
||||||
|
| `killStaleProcess()` | `#safeKill()` + age logic | ✅ Improved |
|
||||||
|
| `probePort()` | `probe()` | ✅ |
|
||||||
|
| `waitForPort()` | `#pollFree()` | ✅ |
|
||||||
|
| `bindPort()` | `claim(server)` + `#bind()` | ✅ |
|
||||||
|
| ss PID lookup | `#identifyHolder()` (method 2) | ✅ |
|
||||||
|
| — | lsof fallback (method 3) | 🆕 |
|
||||||
|
| — | Retry with backoff | 🆕 |
|
||||||
|
| — | EventEmitter state machine | 🆕 |
|
||||||
|
|
||||||
|
### 🐛 Bug Fixes
|
||||||
|
|
||||||
|
- Fixed crash-loop caused by EADDRINUSE race condition during systemd rapid restarts
|
||||||
|
- Fixed `process.exit(1)` on first port conflict — now retries 5 times with backoff
|
||||||
|
- Removed orphaned `net` import from index.js (moved to port-manager.js)
|
||||||
|
|
||||||
|
### 💬 Features
|
||||||
|
|
||||||
|
- Reply context injection: bot now shows `[Replying to <sender>: "<text>"]` when responding to replies
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## [2.0.2] - 2026-05-06
|
## [2.0.2] - 2026-05-06
|
||||||
|
|
||||||
### ⚡ Performance
|
### ⚡ Performance
|
||||||
|
|||||||
Reference in New Issue
Block a user