Preserve CLI environment when adding processes, simplify edit flow, and refresh README docs
- CLI: When adding a process, capture and persist essential environment variables from the CLI (PATH, HOME, USER, SHELL, LANG, LC_ALL, NODE_ENV, NODE_PATH, npm_config_prefix and any TSPM_* variables). Undefined values are removed before storing.
- CLI: Interactive edit flow temporarily disabled. The edit command now displays the current configuration and updates stored environment variables to match the current CLI environment.
- Docs: Major README refresh — reorganized sections, clarified add vs start semantics, expanded examples, added daemon/service usage and programmatic API examples, and improved command reference and output examples.
## 2025-08-30 - 5.1.0 - feat(cli)
Add interactive edit command and update support for process configurations
**TypeScript Process Manager** - A robust, no-fuss process manager designed specifically for TypeScript and Node.js applications. Built for developers who need reliable process management without the complexity.
## 🎯 What TSPM Does
## 🎯 What is TSPM?
TSPM is your production-ready process manager that handles the hard parts of running Node.js applications:
TSPM (TypeScript Process Manager) is your production-ready process manager that handles the hard parts of running Node.js applications. It's like PM2, but built from the ground up for the modern TypeScript ecosystem with better memory management, intelligent logging, and a cleaner architecture.
- **Automatic Memory Management** - Set memory limits and let TSPM handle the rest
- **Smart Auto-Restart** - Crashed processes come back automatically (when you want them to)
- **File Watching** - Auto-restart on file changes during development
- **Process Groups** - Track parent and child processes together
- **Daemon Architecture** - Survives terminal sessions with a persistent background daemon
- **Beautiful CLI** - Clean, informative terminal output with real-time status
- **Structured Logging** - Capture and manage stdout/stderr with intelligent buffering
- **Zero Config** - Works out of the box, customize when you need to
### ✨ Key Features
- **🧠 Smart Memory Management** - Tracks memory including child processes, enforces limits, and auto-restarts when exceeded
- **💾 Persistent Log Storage** - Keeps 10MB of logs in memory, persists to disk on restart/stop/error
-`--lines <n>` - Number of lines to display (default: 50)
-`--follow` - Stream logs in real-time (like `tail -f`)
```bash
# View last 50 lines
tspm logs my-server
# View last 100 lines
tspm logs my-server --lines 100
# Follow logs in real-time
tspm logs my-server --follow
```
### Batch Operations
@@ -180,6 +200,10 @@ Start all saved processes at once.
```bash
tspm start-all
# ✓ Started 3 processes:
# - my-app
# - worker
# - api-server
```
#### `tspm stop-all`
@@ -188,6 +212,7 @@ Stop all running processes.
```bash
tspm stop-all
# ✓ Stopped 3 processes
```
#### `tspm restart-all`
@@ -196,24 +221,49 @@ Restart all running processes.
```bash
tspm restart-all
# ✓ Restarted 3 processes
```
#### `tspm reset`
**⚠️ Dangerous:** Stop all processes and clear all configurations.
```bash
tspm reset
# Are you sure? (y/N)
# Stopped 3 processes.
# Cleared all configurations.
```
### Daemon Management
The TSPM daemon runs in the background and manages all your processes. It starts automatically when needed.
#### `tspm daemon start`
Start the TSPM daemon (happens automatically on first command).
Manually start the TSPM daemon (usually automatic).
```bash
tspm daemon start
# ✓ TSPM daemon started successfully
```
#### `tspm daemon stop`
Stop the TSPM daemon and all managed processes.
Stop the daemon and all managed processes.
```bash
tspm daemon stop
# ✓ TSPM daemon stopped successfully
```
#### `tspm daemon restart`
Restart the daemon (preserves running processes).
```bash
tspm daemon restart
# ✓ TSPM daemon restarted successfully
```
#### `tspm daemon status`
@@ -230,75 +280,175 @@ Status: running
PID: 12345
Uptime: 86400s
Processes: 5
Memory: 45.2 MB
CPU: 0.1%
Socket: /home/user/.tspm/tspm.sock
```
### System Service Management
Run TSPM as a system service (systemd) for production deployments.
#### `tspm enable`
Enable TSPM as a system service that starts on boot.
```bash
sudo tspm enable
# ✓ TSPM daemon enabled and started as system service
# The daemon will now start automatically on system boot
```
#### `tspm disable`
Disable the TSPM system service.
```bash
sudo tspm disable
# ✓ TSPM daemon service disabled
# The daemon will no longer start on system boot
```
## 🏗️ Architecture
TSPM uses a three-tier architecture for maximum reliability:
TSPM uses a robust three-tier architecture:
1.**ProcessWrapper** - Low-level process management with stream handling
2.**ProcessMonitor** - Adds monitoring, memory limits, and auto-restart logic
3.**Tspm Core** - High-level orchestration with configuration persistence
```
┌─────────────────────────────────────────┐
│ CLI Interface │
│ (tspm commands) │
└────────────────┬────────────────────────┘
│ Unix Socket IPC
┌────────────────▼────────────────────────┐
│ TSPM Daemon │
│ (Background Service) │
│ ┌──────────────────────────────────┐ │
│ │ ProcessManager │ │
│ │ - Configuration persistence │ │
│ │ - Process lifecycle │ │
│ │ - Desired state management │ │
│ └────────────┬─────────────────────┘ │
│ │ │
│ ┌────────────▼─────────────────────┐ │
│ │ ProcessMonitor │ │
│ │ - Memory tracking & limits │ │
│ │ - Auto-restart logic │ │
│ │ - Log persistence (10MB) │ │
│ │ - File watching │ │
│ └────────────┬─────────────────────┘ │
│ │ │
│ ┌────────────▼─────────────────────┐ │
│ │ ProcessWrapper │ │
│ │ - Process spawning │ │
│ │ - Stream handling │ │
│ │ - Signal management │ │
│ └──────────────────────────────────┘ │
└─────────────────────────────────────────┘
```
The daemon architecture ensures your processes keep running even after you close your terminal. All process communication happens through a robust IPC (Inter-Process Communication) system.
### Key Components
## 🎮 Programmatic Usage
- **CLI** - Lightweight client that communicates with daemon via IPC
- **Daemon** - Persistent background service managing all processes
- **ProcessManager** - High-level orchestration and configuration
- **ProcessMonitor** - Adds monitoring, limits, and auto-restart
- **ProcessWrapper** - Low-level process lifecycle and streams
TSPM can also be used as a library in your Node.js applications:
## 🎮 Programmatic API
Use TSPM as a library in your Node.js applications:
```typescript
import{Tspm}from'@git.zone/tspm';
import{TspmIpcClient}from'@git.zone/tspm/client';
constmanager=newTspm();
constclient=newTspmIpcClient();
awaitclient.connect();
// Start a process
constprocessId=awaitmanager.start({
id:'worker',
name:'Background Worker',
// Add and start a process
const{id}=awaitclient.request('add', {
command:'node worker.js',
name:'background-worker',
projectDir: process.cwd(),
memoryLimitBytes: 512*1024*1024,// 512MB
memoryLimit: 512*1024*1024,// 512MB in bytes
autorestart: true,
watch: false,
});
// Monitor process
constinfo=awaitmanager.getProcessInfo(processId);
console.log(`Process ${info.id} is ${info.status}`);
TSPM tracks memory usage including all child processes spawned by your application. When a process exceeds its memory limit, it's gracefully restarted.
TSPM tracks total memory usage including all child processes:
- Uses `ps-tree` to discover child processes
- Calculates combined memory usage
- Gracefully restarts when limit exceeded
- Prevents memory leaks in production
### Process Group Tracking
### Log Persistence
Using `ps-tree`, TSPM monitors not just your main process but all child processes it spawns, ensuring complete cleanup on stop/restart.
Intelligent log management system:
- Keeps 10MB of logs in memory per process
- Automatically flushes to disk on stop/restart/error
- Loads previous logs on process restart
- Cleans up persisted logs after loading
- Prevents disk space issues
### Intelligent Logging
### Process Groups
Logs are buffered and managed efficiently, preventing memory issues from excessive output while ensuring you don't lose important information.
Full process tree management:
- Tracks parent and all child processes
- Ensures complete cleanup on stop
- Accurate memory tracking across process trees
- No orphaned processes
### Graceful Shutdown
Processes receive SIGTERM first, allowing them to clean up. After a timeout, SIGKILL ensures termination.
Multi-stage shutdown process:
1. Send SIGTERM for graceful shutdown
2. Wait for process to clean up (5 seconds)
3. Send SIGKILL if still running
4. Clean up all child processes
### Configuration Persistence
### File Watching
Process configurations are saved, allowing you to restart all processes after a system reboot with a single command.
console.log(' Process configuration updated successfully');
},
{actionLabel:'edit process config'},
);
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.