feat(cli/daemon/processmonitor): Add flexible target resolution and search command; improve restart/backoff and error handling
This commit is contained in:
86
readme.md
86
readme.md
@@ -38,21 +38,23 @@ npm install --save-dev @git.zone/tspm
|
||||
# Add a process (creates config without starting)
|
||||
tspm add "node server.js" --name my-server --memory 1GB
|
||||
|
||||
# Start the process
|
||||
tspm start my-server
|
||||
# Start the process (by name or id)
|
||||
tspm start name:my-server
|
||||
# or
|
||||
tspm start id:1
|
||||
|
||||
# Or add and start in one go
|
||||
tspm add "node app.js" --name my-app
|
||||
tspm start my-app
|
||||
tspm start name:my-app
|
||||
|
||||
# List all processes
|
||||
tspm list
|
||||
|
||||
# View logs
|
||||
tspm logs my-app
|
||||
tspm logs name:my-app
|
||||
|
||||
# Stop a process
|
||||
tspm stop my-app
|
||||
tspm stop name:my-app
|
||||
```
|
||||
|
||||
## 📋 Commands
|
||||
@@ -86,38 +88,38 @@ tspm add "tsx watch src/index.ts" --name dev-server --watch --watch-paths "src,c
|
||||
tspm add "node worker.js" --name one-time-job --autorestart false
|
||||
```
|
||||
|
||||
#### `tspm start <id>`
|
||||
#### `tspm start <id|id:N|name:LABEL>`
|
||||
|
||||
Start a previously added process by its ID or name.
|
||||
|
||||
```bash
|
||||
tspm start my-server
|
||||
tspm start 1 # Can also use numeric ID
|
||||
tspm start name:my-server
|
||||
tspm start id:1 # Or a bare numeric id: tspm start 1
|
||||
```
|
||||
|
||||
#### `tspm stop <id>`
|
||||
#### `tspm stop <id|id:N|name:LABEL>`
|
||||
|
||||
Gracefully stop a running process (SIGTERM → SIGKILL after timeout).
|
||||
|
||||
```bash
|
||||
tspm stop my-server
|
||||
tspm stop name:my-server
|
||||
```
|
||||
|
||||
#### `tspm restart <id>`
|
||||
#### `tspm restart <id|id:N|name:LABEL>`
|
||||
|
||||
Stop and restart a process with the same configuration.
|
||||
|
||||
```bash
|
||||
tspm restart my-server
|
||||
tspm restart name:my-server
|
||||
```
|
||||
|
||||
#### `tspm delete <id>` / `tspm remove <id>`
|
||||
#### `tspm delete <id|id:N|name:LABEL>` / `tspm remove <id|id:N|name:LABEL>`
|
||||
|
||||
Stop and remove a process from TSPM management. Also deletes persisted logs.
|
||||
|
||||
```bash
|
||||
tspm delete old-server
|
||||
tspm remove old-server # Alias for delete
|
||||
tspm delete name:old-server
|
||||
tspm remove name:old-server # Alias for delete (daemon handles delete)
|
||||
```
|
||||
|
||||
#### `tspm edit <id>`
|
||||
@@ -148,12 +150,12 @@ tspm list
|
||||
└─────────┴─────────────┴───────────┴───────────┴──────────┴──────────┘
|
||||
```
|
||||
|
||||
#### `tspm describe <id>`
|
||||
#### `tspm describe <id|id:N|name:LABEL>`
|
||||
|
||||
Get detailed information about a specific process.
|
||||
|
||||
```bash
|
||||
tspm describe my-server
|
||||
tspm describe name:my-server
|
||||
|
||||
# Output:
|
||||
Process Details: my-server
|
||||
@@ -173,7 +175,7 @@ Auto-restart: true
|
||||
Watch: disabled
|
||||
```
|
||||
|
||||
#### `tspm logs <id> [options]`
|
||||
#### `tspm logs <id|id:N|name:LABEL> [options]`
|
||||
|
||||
View process logs (stdout and stderr combined).
|
||||
|
||||
@@ -183,13 +185,13 @@ View process logs (stdout and stderr combined).
|
||||
|
||||
```bash
|
||||
# View last 50 lines
|
||||
tspm logs my-server
|
||||
tspm logs name:my-server
|
||||
|
||||
# View last 100 lines
|
||||
tspm logs my-server --lines 100
|
||||
tspm logs name:my-server --lines 100
|
||||
|
||||
# Follow logs in real-time
|
||||
tspm logs my-server --follow
|
||||
tspm logs name:my-server --follow
|
||||
```
|
||||
|
||||
### Batch Operations
|
||||
@@ -496,7 +498,31 @@ Common issues:
|
||||
|
||||
- **"Daemon not running"**: Run `tspm daemon start` or `tspm enable`
|
||||
- **"Permission denied"**: Check socket permissions in `~/.tspm/`
|
||||
- **"Process won't start"**: Check logs with `tspm logs <id>`
|
||||
- **"Process won't start"**: Check logs with `tspm logs <id|id:N|name:LABEL>`
|
||||
|
||||
## 🎯 Targeting Processes (IDs and Names)
|
||||
|
||||
Most process commands accept the following target formats:
|
||||
|
||||
- Numeric ID: `tspm start 1`
|
||||
- Explicit ID: `tspm start id:1`
|
||||
- Explicit name: `tspm start name:api-server`
|
||||
|
||||
Notes:
|
||||
- Names must be used with the `name:` prefix.
|
||||
- If multiple processes share the same name, the CLI will report the ambiguous matches. Use `id:N` to disambiguate.
|
||||
- Use `tspm search <query>` to discover IDs by name or ID fragments.
|
||||
|
||||
### `tspm search <query>`
|
||||
|
||||
Search processes by name or ID substring and print matching IDs (and names when available):
|
||||
|
||||
```bash
|
||||
tspm search api
|
||||
# Matches for "api":
|
||||
# - id:3 name:api-server
|
||||
```
|
||||
|
||||
- **"Memory limit exceeded"**: Increase limit with `tspm edit <id>`
|
||||
|
||||
## 🤝 Why Choose TSPM?
|
||||
@@ -515,6 +541,20 @@ Common issues:
|
||||
|
||||
### Perfect For
|
||||
|
||||
### Restart Backoff and Failure Handling
|
||||
|
||||
TSPM automatically restarts crashed processes with an incremental backoff:
|
||||
|
||||
- Debounce delay grows linearly from 1s up to 10s for consecutive retries.
|
||||
- After the 10th retry, the process is marked as failed (status: "errored") and auto-restarts stop.
|
||||
- The retry counter resets if no retry happens for 1 hour since the last attempt.
|
||||
|
||||
You can manually restart a failed process at any time:
|
||||
|
||||
```bash
|
||||
tspm restart id:1
|
||||
```
|
||||
|
||||
- 🚀 **Production Node.js apps** - Reliable process management
|
||||
- 🔧 **Microservices** - Manage multiple services easily
|
||||
- 👨💻 **Development** - File watching and auto-restart
|
||||
@@ -538,4 +578,4 @@ Registered at District court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||
|
Reference in New Issue
Block a user