This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Procman is a comprehensive process manager with web interface, real-time monitoring, and user management capabilities. It provides daemon/service functionality with HTTP API, WebSocket support, and a React-based frontend for managing processes.
# Build for current platform
go build -o procman ./cmd/procman
# Build with version info (use build.sh for full build)
./build.sh# Linux
GOOS=linux GOARCH=amd64 go build -o procman-linux ./cmd/procman
# Windows
GOOS=windows GOARCH=amd64 go build -o procman.exe ./cmd/procman
# macOS
GOOS=darwin GOARCH=amd64 go build -o procman-macos ./cmd/procman# Run comprehensive tests
./test.sh
# Run specific test scripts
./test-e2e.sh # End-to-end tests
./test-daemon-simple.sh # Daemon functionality tests
./test-concurrency.sh # Concurrency tests
./test-performance.sh # Performance tests
# Manual testing
./procman --help
./procman run # foreground mode for debuggingThe implementation provides a full-featured process management system:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ CLI (main) │───▶│ Daemon │───▶│ HTTP Server │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Process Manager │ │ Auth System │ │ WebSocket Hub │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ Log Management │ │ Terminal Mgmt │
└─────────────────┘ └─────────────────┘
cmd/procman/- CLI entry point with command parsing and HTTP client functionalitypkg/config/- Configuration management (CLI flags, env vars, JSON config)pkg/daemon/- Cross-platform daemon implementation with process managementpkg/server/- HTTP server using Gin with authentication middlewarepkg/process/- Process lifecycle management and monitoringpkg/procfile/- Procfile parsing and validationpkg/auth/- JWT-based authentication with file-based user storagepkg/websocket/- WebSocket hub for real-time communicationpkg/terminal/- Web-based terminal session managementpkg/logstream/- Real-time log streaming and filteringpkg/events/- Event bus for component communicationpkg/storage/- File-based storage mechanismsweb/- React-based frontend application
Configuration is applied in this order (later overrides earlier):
- Default values
- JSON config file (
~/.procman/config.json) - Environment variables (
PROCMAN_*) - Command line flags
start- Start as daemon/background servicestop- Stop running daemonstatus- Check daemon statusrestart- Restart daemonrun- Run in foreground (for debugging)
up- Start all processes or specific processesdown- Stop all processes or specific processesps- List all processes and their statuslogs- Show logs for processes with filtering options
GET /health- Health checkPOST /auth/login- User authenticationGET /api/v1/processes- List all processesPOST /api/v1/processes/:id/start- Start a processPOST /api/v1/processes/:id/stop- Stop a processGET /api/v1/processes/:id/logs- Get process logsGET /api/v1/admin/users- User management (admin only)GET /ws- WebSocket connectionGET /terminal/ws- Terminal WebSocket
- JWT-based authentication with Bearer tokens
- Role-based access control (admin, user, viewer)
- File-based user storage (simple username/password)
- Admin token for system operations
- Linux: Uses fork/exec and PID files
- Windows: Uses Windows service APIs
- Signal handling for graceful shutdown
- Procfile support for process definitions
- Requires Go 1.23 or later
- If system Go version is incompatible, use:
export GOTOOLCHAIN=go1.23.12 - Uses modern Go features including generics and structured logging
The web interface is a React-based SPA located in the web/ directory:
cd web
npm install
npm run dev # Development server
npm run build # Production buildThe codebase implements a complete process management system including:
- Full daemon functionality with process lifecycle management
- HTTP API with authentication and authorization
- Real-time log streaming with WebSocket support
- Web-based terminal access
- React frontend with real-time updates
- Comprehensive test suite
As specified in the project requirements:
- User authentication uses simple file storage (one username per line)
- General storage uses file system or SQLite to avoid external dependencies
- Configuration and data stored in
~/.procman/by default
PROCMAN_PORT- HTTP server port (default: 8080)PROCMAN_PID_FILE- PID file pathPROCMAN_LOG_FILE- Log file pathPROCMAN_DATA_DIR- Data directory pathPROCMAN_ADMIN_TOKEN- Admin authentication token
The project includes comprehensive E2E testing across multiple stages:
- Stage 1: Basic daemon functionality
- Stage 2: Process management operations
- Stage 3: Log streaming and terminal access
- Stage 4: Authentication and user management
- Stage 5: Performance and concurrency testing