Configuration

Configuring ew-npvr

Configuration Overview

ew-npvr is configured through the AgileTV Origin configuration system using a JSON schema, aka confd. The service monitors for configuration changes and adapts dynamically when possible.

Configuration Structure

The configuration is divided into two main sections:

  1. Services Configuration: Channel-level NPVR settings
  2. Storage Configuration: NPVR storage backend and database settings

Services Configuration

Live Ingest Channels

To enable NPVR recording for a live ingest channel, add the npvrLocation property to the channel configuration:

{
  "services": {
    "liveIngest": {
      "channels": [
        {
          "name": "channel-1",
          "state": "enabled",
          "npvrLocation": "storage-location-1"
        }
      ]
    }
  }
}

Parameters:

  • npvrLocation (string): Identifier for the NPVR storage location to use for this channel’s recordings. Must match a configured storage location name.
  • name (string): Channel name
  • state (string): Channel state (must be configured in live ingest)

Note: The channel must already be configured in the live ingest service (ESB3003) before NPVR can record from it.

Storage Configuration

NPVR Storage Locations

Configure one or more storage locations for NPVR recordings:

{
  "storage": {
    "npvr": {
      "locations": [
        {
          "name": "storage-location-1",
          "basePath": "/var/storage/npvr",
          "copyBehavior": "copy",
          "writePacingFactor": 4
        }
      ]
    }
  }
}

Parameters:

  • name (string, required): Unique identifier for this storage location
  • basePath (string, required): Base path for NPVR storage on the filesystem
    • This directory must exist and be writable by the ew-npvr service
    • Ensure sufficient disk space for recordings
  • copyBehavior (string): File copy behavior for NPVR storage
    • copy: Copy files (default) - safer option, works across filesystems
    • hard-link: Create hard links instead of copying - more efficient but requires source and destination on same logical partition
  • writePacingFactor (integer, default 4294967295 = unlimited; min 2, max 4294967295): Paces copy-mode recording writes to N× real-time to avoid write bursts that can exhaust shared storage (NAS) bandwidth. A recording’s content for a given period is written over at least duration / N seconds (for example, factor 4 writes a minute of content in about 15 seconds). A higher value allows faster writes (less throttling); a lower value throttles more aggressively. The default 4294967295 means unlimited (write as fast as possible).
    • Only applies when copyBehavior is copy - hard-link copies create no bytes and are unaffected.
    • Mirrors the ew-cbm catch-up writePacingFactor.

Storage Layout:

Recordings are stored with the following directory structure:

<basePath>/<channelName>/<date>/<hour>/<minute>/...

Metadata is stored in:

<basePath>/<channelName>/metadata/<startTime>-<endTime>/...

Database Configuration

Configure the database connection (PostgreSQL or MySQL). A database address is required; the service refuses to start without one.

{
  "storage": {
    "npvr": {
      "database": {
        "address": "postgres://localhost:5432",
        "user": "npvr_user",
        "password": "secure_password",
        "databaseIndex": "npvr_db"
      }
    }
  }
}

Parameters:

  • address (string, required): Database address, including scheme and port, e.g. postgres://host:5432 or mysql://host:3306. The scheme selects the database driver. There is no default; an empty address is treated as unconfigured.
  • user (string): Username for database authentication
  • password (string): Password for database authentication
  • databaseIndex (string): Database name to use for NPVR

Important Notes:

  • A database address is required. If address is empty or not configured, the service refuses to start (it exits with an error rather than guessing a driver). Configure storage.npvr.database.address before starting the service.

  • Database settings (address, user, password, databaseIndex) are read only at service startup. Changing any of them through confd updates the stored configuration but does not reconnect the running service; the new settings take effect only after the service is restarted (systemctl restart ew-npvr).

  • If the address is configured but the database is unreachable, the service still starts but runs in a degraded mode: it logs the connection error and continues, with the management API unavailable (no ability to create, update, or delete recordings via the API).

  • PostgreSQL and MySQL are supported. To use MySQL, specify the scheme mysql for database address, for example:

confcli storage.npvr.database.address mysql://db.example.com:3306

Similarly, with PostgreSQL:

confcli storage.npvr.database.address postgres://db.example.com:5432

Log Level Configuration

Configure the logging verbosity:

{
  "storage": {
    "npvr": {
      "logLevel": "info"
    }
  }
}

Log Levels:

  • trace: Most verbose, includes all debug information
  • debug: Debug-level messages
  • info: Informational messages (default, recommended for production)
  • warn: Warning messages only
  • error: Error messages only
  • fatal: Fatal errors only
  • panic: Panic-level errors

Important: The log level can be changed dynamically and will take effect immediately without restarting the service.

Complete Configuration Example

{
  "services": {
    "liveIngest": {
      "channels": [
        {
          "name": "channel-1",
          "state": "enabled",
          "npvrLocation": "primary-storage"
        },
        {
          "name": "channel-2",
          "state": "enabled",
          "npvrLocation": "primary-storage"
        },
        {
          "name": "premium-channel",
          "state": "enabled",
          "npvrLocation": "backup-storage"
        }
      ]
    }
  },
  "storage": {
    "npvr": {
      "logLevel": "info",
      "locations": [
        {
          "name": "primary-storage",
          "basePath": "/mnt/npvr/storage1",
          "copyBehavior": "copy"
        },
        {
          "name": "backup-storage",
          "basePath": "/mnt/npvr/storage2",
          "copyBehavior": "hard-link"
        }
      ],
      "database": {
        "address": "postgresql://db.example.com:5432",
        "user": "npvr_service",
        "password": "secret_password",
        "databaseIndex": "npvr_production"
      }
    }
  }
}

Dynamic Configuration Updates

The service monitors configuration changes and applies them dynamically when possible:

  • Log Level: Applied immediately without restart
  • Storage Locations: Applied immediately without restart
  • Database Settings: Requires restart to take effect
  • Channel NPVR Locations: Applied immediately when channels are updated

Troubleshooting Configuration

Common configuration issues:

  1. Service exits immediately on start: The database address is empty or not configured. Set storage.npvr.database.address (including scheme and port) and restart.
  2. Database connection fails: Address is configured but the database is unreachable - service continues in degraded mode (no management API); check logs for connection errors.
  3. Storage path not writable: Check file permissions and disk space
  4. Hard-link fails: Verify source and destination are on same filesystem, or use copy instead