Skip to main content

CLI Reference

This reference documents all command-line flags and options for the nekzus binary.

Command Structure

Nekzus uses a simple command structure with flags to control behavior:

nekzus [flags]

The binary is designed to run as a long-running server process. All configuration can be done via command-line flags, environment variables, or configuration files.


Flags and Options

Primary Flags

FlagTypeDefaultDescription
--configstringconfigs/config.example.yamlPath to configuration file (YAML or JSON)
--insecure-httpboolfalseServe HTTP without TLS (development only)
--healthboolfalsePerform health check against running server and exit
--health-addrstringhttp://localhost:8080Address for health check endpoint

Flag Details

--config

Specifies the path to the configuration file. Supports YAML (.yaml, .yml) and JSON (.json) formats.

Using a custom configuration file
nekzus --config /etc/nekzus/config.yaml
Using JSON configuration
nekzus --config /path/to/config.json
Configuration Priority

Configuration is loaded in this order (later sources override earlier):

  1. Default values (built-in)
  2. Configuration file (--config)
  3. Environment variables (NEKZUS_*)

--insecure-http

Disables TLS and serves plain HTTP. This flag is intended for development environments only.

Development mode without TLS
nekzus --config configs/config.yaml --insecure-http
Security Warning

Never use --insecure-http in production. It disables HTTPS encryption, exposing all traffic including authentication tokens.

When this flag is set, the server:

  • Ignores tls_cert and tls_key configuration values
  • Listens on plain HTTP instead of HTTPS
  • Logs a warning about insecure operation

--health

Performs a health check against a running Nekzus instance and exits. This is designed for use in container health checks (Docker, Kubernetes).

Health check against local server
nekzus --health
Health check against remote server
nekzus --health --health-addr https://192.168.1.100:8443

The health check:

  • Calls the /api/v1/healthz endpoint
  • Uses a 5-second timeout
  • Skips TLS certificate verification (for self-signed certificates)
  • Returns exit code 0 for healthy, 1 for unhealthy

--health-addr

Specifies the address to check when running with --health. Use this when the server is running on a non-default port or remote host.

Check remote server health
nekzus --health --health-addr https://nekzus.local:8443

Environment Variables

Environment variables override configuration file values. All environment variables use the NEKZUS_ prefix.

Core Variables

VariableDescriptionDefault
NEKZUS_ADDRServer listen address (e.g., :8080, 0.0.0.0:8443):8443
NEKZUS_TLS_CERTPath to TLS certificate file(none)
NEKZUS_TLS_KEYPath to TLS private key file(none)
NEKZUS_JWT_SECRETJWT signing secret (minimum 32 characters)(auto-generated)
NEKZUS_BOOTSTRAP_TOKENAdditional bootstrap token for device pairing(none)
NEKZUS_DATABASE_PATHPath to SQLite database file./data/nexus.db
NEKZUS_BASE_URLPublic URL for QR code pairing(auto-detected)
NEKZUS_DEBUGEnable debug logging (true or 1)false

Feature Variables

VariableDescriptionDefault
NEKZUS_DISCOVERY_ENABLEDEnable service discovery(from config)
NEKZUS_DISCOVERY_DOCKER_ENABLEDEnable Docker discovery(from config)
NEKZUS_TOOLBOX_ENABLEDEnable toolbox functionality(from config)
NEKZUS_TOOLBOX_HOST_DATA_DIRHost path for toolbox data (Docker-in-Docker)(none)
NEKZUS_METRICS_ENABLEDEnable Prometheus metrics endpoint(from config)
NEKZUS_HOST_ROOT_PATHHost root path for system metrics(none)

Environment Variable Examples

export NEKZUS_ADDR=":8080"
export NEKZUS_JWT_SECRET="$(openssl rand -base64 32)"
nekzus --insecure-http

Exit Codes

Nekzus uses standard Unix exit codes:

CodeMeaningDescription
0SuccessNormal shutdown or healthy status (with --health)
1ErrorConfiguration error, initialization failure, or unhealthy status

Exit Code Scenarios

Exit code 0:

  • Server receives SIGINT or SIGTERM and shuts down gracefully
  • Health check (--health) reports server is healthy

Exit code 1:

  • Configuration file not found or invalid
  • Configuration validation fails
  • Database initialization fails
  • TLS certificate loading fails
  • Health check (--health) reports server is unhealthy or unreachable

Signals

Nekzus handles the following Unix signals:

SignalBehavior
SIGINT (Ctrl+C)Graceful shutdown with 30-second timeout
SIGTERMGraceful shutdown with 30-second timeout

Graceful Shutdown Sequence

When a shutdown signal is received:

  1. Stop accepting new connections
  2. Stop configuration watcher
  3. Stop discovery workers
  4. Stop service health checker
  5. Stop scheduled jobs (backups, scripts)
  6. Stop notification queue
  7. Stop federation peer manager
  8. Drain and close WebSocket connections
  9. Close HTTP server with active request draining
  10. Close Docker client
  11. Close database connection

Usage Examples

Basic Server Start

Start with default configuration
nekzus --config configs/config.yaml

Development Mode

Start without TLS for local development
nekzus --config configs/config.yaml --insecure-http

Production Deployment

Production with custom paths
nekzus --config /etc/nekzus/config.yaml

Container Health Check

Use in Docker health check or Kubernetes liveness probe:

docker-compose.yml
services:
nekzus:
image: nstalgic/nekzus:latest
healthcheck:
test: ["/app/nekzus", "--health"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s

Make Targets

When running from source, the Makefile provides convenience targets:

TargetCommandDescription
make rungo run ./cmd/nekzus --config configs/config.yamlRun with TLS
make run-insecurego run ./cmd/nekzus --config configs/config.yaml --insecure-httpRun without TLS
make buildgo build -o bin/nekzus ./cmd/nekzusBuild binary
make build-allBuild web UI and Go binaryComplete build
make demoStart demo environment with Docker ComposeDemo with example services

Running from Source

Development workflow
# Build everything
make build-all

# Run with TLS (auto-generates certificates)
make run

# Run without TLS (development)
make run-insecure

# Run demo environment with test services
make demo

Debug Mode

Enable debug logging for troubleshooting:

NEKZUS_DEBUG=true nekzus --config configs/config.yaml

Debug mode enables:

  • Verbose structured logging at DEBUG level
  • Additional context in log messages
  • Performance timing information

Version Information

The version is embedded at build time via ldflags:

Check version
nekzus --version  # Note: version flag not exposed, check logs on startup

The version is displayed in:

  • Server startup logs (nekzus starting version=X.X.X)
  • API endpoint /api/v1/admin/info
  • Prometheus metrics (nekzus_build_info)

Build with Custom Version

Build with version tag
go build -ldflags="-X main.version=v1.2.3" -o nekzus ./cmd/nekzus

Configuration File Reference

For detailed configuration file options, see the Configuration Reference.

Quick reference for commonly used configuration sections:

Minimal configuration
server:
addr: ":8080"

auth:
issuer: "nekzus"
audience: "nekzus-mobile"
# hs256_secret: Set via NEKZUS_JWT_SECRET env var

storage:
database_path: "./data/nexus.db"

discovery:
enabled: true
docker:
enabled: true

Troubleshooting

Common Issues

Server fails to start with 'failed to load TLS certificate'

This occurs when TLS certificate paths are configured but files are missing or invalid.

Solutions:

  1. Use --insecure-http for development
  2. Ensure certificate files exist at the specified paths
  3. Remove tls_cert and tls_key from config to auto-generate certificates
# Development without TLS
nekzus --config configs/config.yaml --insecure-http
Health check returns unhealthy

Check connectivity and ensure the server is running:

# Check if server is responding
curl -k https://localhost:8443/api/v1/healthz

# Check with verbose health output
nekzus --health --health-addr https://localhost:8443
Configuration validation fails

Common validation errors:

  • hs256_secret must be at least 32 characters: Use a longer JWT secret
  • server.addr: invalid address format: Use format :8080 or 0.0.0.0:8080
  • routes[X].path_base must start with /: Ensure route paths start with /

Run with debug mode to see detailed validation errors:

NEKZUS_DEBUG=true nekzus --config configs/config.yaml
Environment variables not being applied

Environment variables are applied after loading the config file. Verify:

  1. Variable names use the NEKZUS_ prefix
  2. Boolean values use true/false or 1/0
  3. No typos in variable names
# List all NEKZUS_ environment variables
env | grep NEKZUS_

See Also