fix(cli): improve project metadata loading and normalize CLI error handling
This commit is contained in:
@@ -15,7 +15,7 @@ TSPM is your production-ready process manager that handles the hard parts of run
|
||||
- 🧠 **Smart Memory Management** — Tracks memory across entire process trees (parent + children), enforces limits, and auto-restarts on OOM
|
||||
- 💾 **Persistent Log Storage** — 10MB in-memory ring buffer per process, auto-persists to disk on stop/restart/crash
|
||||
- 🔄 **Intelligent Auto-Restart** — Crashed processes restart with incremental backoff (1s → 10s), auto-stop after 10 consecutive failures
|
||||
- 👀 **File Watching** — Auto-restart on file changes for seamless development workflows
|
||||
- 🧾 **Persistent Process Configs** — Saved process definitions and desired states survive daemon restarts
|
||||
- 🌳 **Process Tree Tracking** — Monitors parent and all child processes as a unit — no orphans, ever
|
||||
- 🏗️ **Daemon Architecture** — Persistent background service that survives terminal sessions via Unix socket IPC
|
||||
- 📊 **Beautiful CLI** — Clean, informative output with table views, real-time log streaming, and search
|
||||
@@ -83,8 +83,8 @@ Register a new process configuration (without starting it).
|
||||
| `--name <name>` | Process name | command string |
|
||||
| `--memory <size>` | Memory limit (e.g. `512MB`, `2GB`) | `512MB` |
|
||||
| `--cwd <path>` | Working directory | current directory |
|
||||
| `--watch` | Enable file watching | `false` |
|
||||
| `--watch-paths <paths>` | Comma-separated watch paths | — |
|
||||
| `--watch` | Store watch intent in the process config | `false` |
|
||||
| `--watch-paths <paths>` | Comma-separated watch paths stored with the config | — |
|
||||
| `--autorestart` | Auto-restart on crash | `true` |
|
||||
| `-i, --interactive` | Enter interactive edit after adding | — |
|
||||
|
||||
@@ -95,8 +95,8 @@ tspm add "node server.js" --name api-server
|
||||
# TypeScript with 2GB memory limit
|
||||
tspm add "tsx src/index.ts" --name production-api --memory 2GB
|
||||
|
||||
# Dev mode with file watching
|
||||
tspm add "tsx watch src/index.ts" --name dev-server --watch --watch-paths "src,config"
|
||||
# TypeScript entry file (runs through tsx automatically)
|
||||
tspm add ./src/index.ts --name ts-worker --memory 2GB
|
||||
|
||||
# One-shot worker (no auto-restart)
|
||||
tspm add "node worker.js" --name batch-job --autorestart false
|
||||
@@ -131,12 +131,13 @@ Stop and restart a process, preserving its configuration.
|
||||
tspm restart name:my-server
|
||||
```
|
||||
|
||||
#### `tspm delete <target>`
|
||||
#### `tspm delete <target>` / `tspm remove <target>`
|
||||
|
||||
Stop, remove from management, and delete persisted logs.
|
||||
|
||||
```bash
|
||||
tspm delete name:old-server
|
||||
tspm remove id:3
|
||||
```
|
||||
|
||||
#### `tspm edit <target>`
|
||||
@@ -161,16 +162,16 @@ tspm search api
|
||||
|
||||
#### `tspm list`
|
||||
|
||||
Display all managed processes in a table.
|
||||
Display all managed processes with live runtime stats. Use `tspm describe <target>` for saved command, directory, and full process configuration details.
|
||||
|
||||
```
|
||||
┌─────┬─────────────┬──────────┬───────┬──────────┬──────────┐
|
||||
│ ID │ Name │ Status │ PID │ Memory │ Restarts │
|
||||
├─────┼─────────────┼──────────┼───────┼──────────┼──────────┤
|
||||
│ 1 │ my-app │ online │ 45123 │ 245.3 MB │ 0 │
|
||||
│ 2 │ worker │ online │ 45456 │ 128.7 MB │ 2 │
|
||||
│ 3 │ api-server │ stopped │ - │ 0 B │ 5 │
|
||||
└─────┴─────────────┴──────────┴───────┴──────────┴──────────┘
|
||||
┌─────────┬─────────────┬───────────┬───────────┬──────────┬──────────┬─────────┐
|
||||
│ ID │ Name │ Status │ PID │ Memory │ CPU │ Restarts │
|
||||
├─────────┼─────────────┼───────────┼───────────┼──────────┼──────────┼──────────┤
|
||||
│ 1 │ 1 │ online │ 45123 │ 245.3 MB │ 2.1% │ 0 │
|
||||
│ 2 │ 2 │ online │ 45456 │ 128.7 MB │ 0.5% │ 2 │
|
||||
│ 3 │ 3 │ stopped │ - │ 0 B │ - │ 5 │
|
||||
└─────────┴─────────────┴───────────┴───────────┴──────────┴──────────┴──────────┘
|
||||
```
|
||||
|
||||
#### `tspm describe <target>`
|
||||
@@ -194,7 +195,6 @@ tspm describe name:my-server
|
||||
# Directory: /home/user/project
|
||||
# Memory Limit: 2 GB
|
||||
# Auto-restart: true
|
||||
# Watch: disabled
|
||||
```
|
||||
|
||||
#### `tspm logs <target> [options]`
|
||||
@@ -230,18 +230,20 @@ tspm logs name:my-server --since 10m --ndjson
|
||||
tspm start-all # Start all saved processes
|
||||
tspm stop-all # Stop all running processes
|
||||
tspm restart-all # Restart all running processes
|
||||
tspm restart all # Alternate all-process restart form
|
||||
tspm reset # ⚠️ Stop all + clear all configs (prompts for confirmation)
|
||||
```
|
||||
|
||||
### Daemon Management
|
||||
|
||||
The daemon is a persistent background service that manages all processes. It starts automatically when needed.
|
||||
The daemon is a persistent background service that manages all processes. Start it explicitly for the current session, or install it as a systemd service for boot startup.
|
||||
|
||||
```bash
|
||||
tspm daemon start # Start the daemon
|
||||
tspm daemon stop # Stop daemon + all managed processes
|
||||
tspm daemon restart # Restart daemon (preserves processes)
|
||||
tspm daemon status # Check daemon health + stats
|
||||
tspm stats # Detailed daemon stats + process table
|
||||
```
|
||||
|
||||
### System Service (systemd)
|
||||
@@ -285,7 +287,7 @@ TSPM uses a clean three-tier architecture:
|
||||
│ │ - Memory tracking & limits │ │
|
||||
│ │ - Auto-restart logic │ │
|
||||
│ │ - Log persistence (10MB) │ │
|
||||
│ │ - File watching │ │
|
||||
│ │ - Desired state restoration │ │
|
||||
│ └────────────┬─────────────────────┘ │
|
||||
│ │ │
|
||||
│ ┌────────────▼─────────────────────┐ │
|
||||
@@ -310,7 +312,7 @@ TSPM uses a clean three-tier architecture:
|
||||
| **CLI** | Lightweight client that sends commands to daemon via IPC |
|
||||
| **Daemon** | Persistent background service managing all processes |
|
||||
| **ProcessManager** | High-level orchestration, config persistence, state management |
|
||||
| **ProcessMonitor** | Memory limits, auto-restart with backoff, log persistence, file watching |
|
||||
| **ProcessMonitor** | Memory limits, auto-restart with backoff, log persistence, process-tree stats |
|
||||
| **ProcessWrapper** | Low-level process lifecycle, stream handling, signal management |
|
||||
| **CrashLogManager** | Detailed crash reports with metadata and log history |
|
||||
|
||||
@@ -399,14 +401,9 @@ Multi-stage shutdown for reliability:
|
||||
3. Send **SIGKILL** if still alive
|
||||
4. Clean up **all child processes** in the tree
|
||||
|
||||
### File Watching
|
||||
### TypeScript Entry Files
|
||||
|
||||
Development-friendly auto-restart:
|
||||
|
||||
- Watch specific directories or files
|
||||
- `node_modules` ignored by default
|
||||
- Debounced restart on file changes
|
||||
- Configurable via `--watch-paths`
|
||||
If `tspm add` receives a single `.ts` file, TSPM resolves it through `tsx` automatically and stores the resolved command plus file argument in the process config. Full command strings are still executed through the shell, so existing `node`, `tsx`, `pnpm`, or custom commands work as expected.
|
||||
|
||||
## 🐛 Debugging
|
||||
|
||||
@@ -417,8 +414,11 @@ tspm daemon status
|
||||
# View process logs
|
||||
tspm logs name:my-app --lines 200
|
||||
|
||||
# Check daemon stderr
|
||||
tail -f /tmp/daemon-stderr.log
|
||||
# Start with verbose daemon diagnostics
|
||||
TSPM_DEBUG=true tspm daemon start
|
||||
|
||||
# For systemd-managed daemon logs
|
||||
journalctl -u smartdaemon_tspm-daemon -f
|
||||
|
||||
# Force daemon restart
|
||||
tspm daemon restart
|
||||
@@ -449,13 +449,13 @@ tspm daemon restart
|
||||
|
||||
- 🚀 **Production Node.js apps** — Reliable process management with memory guards
|
||||
- 🔧 **Microservices** — Manage multiple services from a single tool
|
||||
- 👨💻 **Development** — File watching and instant auto-restart
|
||||
- 👨💻 **Development** — TypeScript entry files, local workers, and quick daemon lifecycle commands
|
||||
- 🏭 **Workers & Jobs** — Queue workers, cron jobs, background tasks
|
||||
- 📊 **Resource-constrained environments** — Memory limits prevent OOM kills
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./license) file.
|
||||
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [license](./license) file.
|
||||
|
||||
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||
|
||||
@@ -467,7 +467,7 @@ Use of these trademarks must comply with Task Venture Capital GmbH's Trademark G
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH
|
||||
Task Venture Capital GmbH
|
||||
Registered at District Court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or further information, please contact us via email at hello@task.vc.
|
||||
|
||||
Reference in New Issue
Block a user