Agent Guide

The Orion Agent is a compiled Linux binary that runs as a systemd daemon. It sends system metrics (CPU, RAM, disk, network), manages application processes, and streams their stdout/stderr to Orion.

Installation

curl -fsSL https://install.orion.dev | bash

This installs the orion binary to /usr/local/bin/orion and the systemd service file.

Setup

Setup is a two-step process: server-wide (once per machine) then source (once per application).

Step 1 — Server setup

sudo orion setup --server

This interactive wizard:

  • Authenticates via browser or API token
  • Lets you select or create a project
  • Registers the server with Orion (using hostname as the stable ID)
  • Writes /etc/orion/config.json

After setup, enable and start the daemon:

sudo systemctl enable --now orion-agent

Step 2 — Source setup

Run this inside each application directory:

orion setup --source

This wizard:

  • Selects or creates a source in your project
  • Prompts for the application's start command (e.g. node dist/index.js)
  • Configures auto-restart and output capture
  • Writes .orion/config.json (the same format the SDK reads)
  • Registers the script in /etc/orion/scripts.json

CLI commands

# Check daemon status + live metrics + script states
orion status

# Send a one-off log from the terminal
orion log info "Deploy complete"
orion log error "Disk space low"

# Script management
orion script start <name>
orion script stop <name>
orion script restart <name>
orion script list
orion script add <name> <command> [--cwd <path>] [--no-auto-restart] [--no-capture]

Script management

The agent manages application processes defined in /etc/orion/scripts.json. Each script entry:

{
  "name": "api-backend",
  "command": "node dist/index.js",
  "cwd": "/opt/myapp",
  "autoRestart": true,
  "maxRestarts": 5,
  "backoffBase": 1000,
  "captureOutput": true
}
FieldDescription
nameUnique identifier (lowercase, hyphens)
commandShell command to execute
cwdWorking directory
autoRestartRestart on crash with exponential backoff
maxRestartsStop after N consecutive crashes
backoffBaseInitial backoff in ms (doubles each restart, max 60s)
captureOutputStream stdout/stderr to Orion as logs

When a script crashes, the agent always sends an alert to Orion — even if autoRestart is false.

Heartbeat

Every 30 seconds the daemon sends a heartbeat to POST /api/v1/agent/heartbeat with:

  • CPU usage (%)
  • RAM (used MB / total MB / %)
  • Disk (used GB / total GB / %)
  • Network (rx/tx bytes per second)
  • Uptime (seconds)
  • Script states (running / stopped / crashed)

Offline buffer

If the backend is unreachable, logs are buffered to /etc/orion/buffer.jsonl. The agent retries with exponential backoff (5s → 10s → 30s → 60s) and flushes in order when reconnected. Maximum buffer size: 10,000 entries (oldest dropped first).

File locations

PathPurpose
/usr/local/bin/orionThe binary
/etc/orion/config.jsonServer-wide config (token, apiUrl, heartbeatInterval)
/etc/orion/scripts.jsonManaged scripts registry
/etc/orion/buffer.jsonlOffline log buffer
/var/log/orion-agent.logInternal agent logs
/run/orion/agent.sockIPC Unix socket (CLI ↔ daemon)
.orion/config.jsonPer-application source token

IPC protocol

CLI commands communicate with the daemon over a Unix socket at /run/orion/agent.sock. Each message is a JSON line terminated by \n:

{ "cmd": "script:start", "name": "api-backend" }
{ "cmd": "script:list" }
{ "cmd": "status" }
{ "cmd": "log", "level": "info", "message": "Deploy done" }

Daemon responses:

{ "ok": true, "data": { ... } }
{ "ok": false, "error": "Script not found" }