Skip to main content

Daemon Commands (nikd)

The nikd daemon is the background service that executes background agent jobs. It provides a REST API for job management and handles job queuing, execution, and monitoring.

Installation

Commands Overview

nikd start

Start the background agent daemon with specified configuration. Syntax:
Options: Examples:
Configuration Details: Port Configuration:
  • Default port is 3000
  • Must be available and not in use
  • Used for REST API and health checks
Redis Configuration:
  • Optional external Redis for job queue
  • Format: redis://[username:password@]host:port[/database]
  • Falls back to local in-memory queue if not specified
  • Required for multi-instance deployments
GitHub Integration:
  • Enables automatic PR creation and management
  • Requires GitHub App with appropriate permissions
  • Private key must be accessible to daemon process
Workspace Configuration:
  • Directory where jobs execute
  • Must have read/write permissions
  • Should have sufficient disk space for repositories

nikd status

Check the daemon status and health information. Syntax:
Options:
  • --api-url <url> - API server URL (default: http://localhost:3000)
Examples:
Status Information:
  • Daemon running status
  • API endpoint availability
  • Uptime information
  • Last health check timestamp
  • Version information
Exit Codes:
  • 0 - Daemon is running and healthy
  • 1 - Daemon is not running or unreachable

nikd logs

Stream daemon logs (placeholder for future implementation). Syntax:
Options:
  • --api-url <url> - API server URL (default: http://localhost:3000)
Current Behavior:
  • Shows connection information
  • Notes that real-time logs require additional implementation
  • Suggests checking daemon console output
Future Implementation:
  • Real-time log streaming via WebSocket
  • Log filtering and search capabilities
  • Historical log access

Configuration

Environment Variables

The daemon supports configuration via environment variables:

Configuration File

Create /etc/nikd/config.json or ~/.nikd/config.json:

API Endpoints

The daemon exposes a REST API for job management:

Health Check

Response:

Job Management

Metrics

Deployment

Docker Deployment

Dockerfile:
docker-compose.yml:
Run with Docker:

Kubernetes Deployment

deployment.yaml:

Systemd Service

nikd.service:
Installation:

Monitoring

Health Monitoring

Basic health check:
Advanced monitoring script:

Prometheus Metrics

metrics endpoint:
Sample metrics:

Troubleshooting

Common Issues

Daemon won’t start:
Jobs stuck in queue:
Memory issues:
GitHub integration issues:

Debug Mode

Enable debug logging:

Log Analysis

Common log patterns:

Security

Best Practices

  1. Network Security:
    • Run behind reverse proxy (nginx, traefik)
    • Use HTTPS in production
    • Restrict API access with firewall rules
  2. Authentication:
    • Use API keys for external access
    • Implement JWT tokens for session management
    • Rotate secrets regularly
  3. Resource Isolation:
    • Run jobs in containers or VMs
    • Limit resource usage per job
    • Implement proper cleanup
  4. Data Protection:
    • Encrypt sensitive configuration
    • Use secrets management (Vault, K8s secrets)
    • Audit log access

Security Configuration