runtime - nself-org/cli GitHub Wiki
Commands: start, stop, restart, logs, ps, health
Complete plugin lifecycle management as external Node.js processes.
The plugin runtime system allows you to run nself plugins as external Node.js processes with full lifecycle management, automatic setup, and health monitoring.
Auto-Handled:
- โ Shared utilities build (one-time)
- โ
Dependencies installation (
pnpm install) - โ
TypeScript compilation (
pnpm build) - โ
Environment setup (
.envwith DATABASE_URL + ENCRYPTION_KEY) - โ Process management (PIDs, logs, graceful shutdown)
- โ
Health checks via
/healthendpoints
Start one or all installed plugins.
Usage:
nself plugin start <name> # Start specific plugin
nself plugin start --all # Start all installed plugins
nself plugin start -a # Same as --allWhat It Does:
- Checks if shared utilities are built (builds if needed)
- Installs dependencies if
node_modules/missing - Compiles TypeScript if
dist/missing - Creates
.envfile with DATABASE_URL and ENCRYPTION_KEY - Starts plugin in background
- Saves PID to
~/.nself/runtime/pids/<name>.pid - Logs to
~/.nself/runtime/logs/<name>.log
Examples:
# Start single plugin
nself plugin start vpn
# Start all plugins
cd ~/Sites/myproject/backend
nself plugin start --allOutput:
โน Starting vpn...
โ vpn started (PID: 12345)
Logs: nself plugin logs vpn
Stop one or all running plugins.
Usage:
nself plugin stop <name> # Stop specific plugin
nself plugin stop --all # Stop all running plugins
nself plugin stop -a # Same as --allWhat It Does:
- Sends SIGTERM for graceful shutdown
- Waits up to 5 seconds
- Sends SIGKILL if still running
- Removes PID file
Examples:
# Stop single plugin
nself plugin stop vpn
# Stop all running plugins
nself plugin stop --allOutput:
โน Stopping vpn (PID: 12345)...
โ vpn stopped
Restart a running plugin (stop + start).
Usage:
nself plugin restart <name>Examples:
# Restart after code changes
nself plugin restart vpn
# After updating .env
nself plugin restart torrent-managerView plugin logs.
Usage:
nself plugin logs <name> # Show last 50 lines
nself plugin logs <name> -f # Follow logs (live tail)
nself plugin logs <name> --follow # Same as -fLog Location: ~/.nself/runtime/logs/<name>.log
Examples:
# View recent logs
nself plugin logs vpn
# Follow logs live (Ctrl+C to exit)
nself plugin logs vpn -f
# Debug startup issues
nself plugin start discovery
nself plugin logs discoveryOutput:
2026-02-14T22:12:44.078Z INFO [vpn:config] Configuration loaded
2026-02-14T22:12:44.162Z INFO [vpn:main] ๐ Starting VPN Plugin...
2026-02-14T22:12:44.163Z INFO [vpn:database] Initializing database schema
List all running plugins (alias: running).
Usage:
nself plugin ps
nself plugin running # Same commandExamples:
nself plugin psOutput:
=== Running Plugins ===
vpn PID: 12345 Port: 3200
torrent-manager PID: 12346 Port: 3201
content-acquisition PID: 12347 Port: 3202
subtitle-manager PID: 12348 Port: 3204
Total: 4 running
Health check all running plugins.
Usage:
nself plugin healthWhat It Does:
- Checks if process is running (PID exists)
- Reads port from
.env - Tries HTTP GET
http://localhost:<port>/health - Reports status for each plugin
Examples:
nself plugin healthOutput:
=== Plugin Health Check ===
โ
vpn - Healthy (port 3200)
โ
torrent-manager - Healthy (port 3201)
โ ๏ธ discovery - Running but not responding (port 3000)
โ metadata-enrichment - Not running
3/4 plugins healthy
When starting a plugin, the CLI auto-creates ~/.nself/plugins/<name>/ts/.env with:
# Auto-generated by nself plugin start
DATABASE_URL=postgresql://user:pass@host:port/database
ENCRYPTION_KEY=<random-32-char-key>
PORT=<from-plugin.json>
LOG_LEVEL=infoDATABASE_URL Detection:
The CLI reads your project's .env files in order:
-
.env.dev(checked first) .env.local.env
It looks for either:
DATABASE_URL=<full-connection-string>- Or builds from:
POSTGRES_USER,POSTGRES_PASSWORD,POSTGRES_DB,POSTGRES_HOST,POSTGRES_PORT
ENCRYPTION_KEY Generation:
Stored at ~/.nself/encryption.key (generated once, reused for all plugins).
To customize plugin environment:
# Edit the auto-generated .env
vim ~/.nself/plugins/vpn/ts/.env
# Add plugin-specific variables
echo "VPN_PROVIDER=nordvpn" >> ~/.nself/plugins/vpn/ts/.env
# Restart to apply
nself plugin restart vpn~/.nself/
โโโ shared/ # Symlink to plugins/_shared (auto-created)
โโโ encryption.key # Master encryption key (auto-generated)
โโโ plugins/
โ โโโ _shared/ # Shared utilities for all plugins
โ โ โโโ dist/ # Built shared code
โ โโโ vpn/
โ โโโ plugin.json # Plugin manifest
โ โโโ ts/
โ โโโ .env # Auto-generated environment
โ โโโ node_modules/ # Auto-installed dependencies
โ โโโ dist/ # Auto-compiled TypeScript
โ โโโ src/ # Plugin source code
โโโ runtime/
โโโ logs/ # Plugin logs
โ โโโ vpn.log
โ โโโ torrent-manager.log
โ โโโ ...
โโโ pids/ # Process IDs
โโโ vpn.pid
โโโ torrent-manager.pid
โโโ ...
# Check logs
nself plugin logs <name>
# Common issues:
# 1. Missing database tables
nself plugin <name> init
# 2. TypeScript compilation errors
cd ~/.nself/plugins/<name>/ts
pnpm build
# 3. Missing dependencies
cd ~/.nself/plugins/<name>/ts
pnpm installEnsure your project has .env with database credentials:
# Option 1: Direct URL
DATABASE_URL=postgresql://user:pass@host:port/database
# Option 2: Individual vars (auto-composed)
POSTGRES_USER=postgres
POSTGRES_PASSWORD=mypassword
POSTGRES_DB=myproject_db
POSTGRES_HOST=localhost
POSTGRES_PORT=5432If you see "Shared utilities not found":
cd ~/Sites/nself-plugins/shared
pnpm install && pnpm build
# Then retry
nself plugin start --all# Find what's using the port
lsof -i :3200
# Stop the conflicting process
# Or change plugin port in .env
vim ~/.nself/plugins/vpn/ts/.env
# Change: PORT=3200 โ PORT=3210
nself plugin restart vpn# 1. Start your nself backend
cd ~/Sites/myproject/backend
nself start
# 2. Install plugins you need
nself plugin install vpn
nself plugin install torrent-manager
nself plugin install subtitle-manager
# 3. Start all plugins
nself plugin start --all
# 4. Check status
nself plugin ps
# 5. Health check
nself plugin health
# 6. View logs
nself plugin logs vpn -f
# 7. Run your application (plugins are available via HTTP)
pnpm dev
# 8. Stop when done
nself plugin stop --all
nself stopPlugins can run either as:
Option A: External Processes (current approach)
- โ Simple setup
- โ Auto-handled dependencies
- โ Easy debugging (logs, restart)
- โ Manual process management
Option B: Docker via CS_N
# Add to .env
CS_1=vpn:express-js:3200
CS_2=torrent-manager:express-js:3201
# Build and start
nself build && nself start- โ Unified with other services
- โ Auto-restart on failure
- โ More complex setup
- โ Shared utilities path issues
Recommendation: Use external processes (Option A) during development, Docker (Option B) for production.
-
nself plugin install <name>- Install a plugin -
nself plugin update <name>- Update plugin to latest version -
nself plugin status- Show plugin installation status -
nself plugin <name> init- Initialize plugin database schema -
nself plugin <name> integrate- Get CS_N Docker configuration