tutorial

Monitoring Refact.ai with Vigilmon

Refact.ai is a self-hosted AI coding assistant with a web dashboard for teams — but when the server, GPU, or analytics pipeline goes down, developers lose completions silently. Here's how to monitor Refact.ai's availability, inference health, and SSL with Vigilmon.

Refact.ai is an open-source, self-hosted AI coding assistant platform. It delivers code completion, chat, and automated code review to VS Code and JetBrains IDEs — backed by models like CodeLlama, StarCoder, and DeepSeek Coder — and includes a web dashboard for managing team access, model selection, and productivity analytics. The Python server runs on port 8008. Vigilmon monitors the server, every critical API endpoint, the web dashboard, GPU utilization, and the SSL certificate so your team always has working completions.

What You'll Set Up

  • Refact server process availability monitor (port 8008)
  • Code completion API health check (POST /v1/completions)
  • Chat API health check (POST /v1/chat/completions)
  • Web dashboard availability monitor
  • GPU / model inference health heartbeat
  • Usage analytics pipeline heartbeat
  • SSL certificate expiry alerts

Prerequisites

  • Refact.ai server running: docker run -d -p 8008:8008 smallcloudai/refact (or native install)
  • IDE extensions configured to point to your self-hosted server
  • A free Vigilmon account

Step 1: Monitor the Refact Server Process

The Refact Python server (port 8008) handles all IDE completion requests, web dashboard traffic, and team authentication. A crash takes down everything simultaneously — completions, chat, and the admin dashboard.

  1. Log in to vigilmon.online and click Add Monitor.
  2. Set Type to HTTP / HTTPS.
  3. Enter the Refact server URL:
    http://your-host:8008/
    
    Or if behind a TLS reverse proxy:
    https://refact.yourdomain.com/
    
  4. Set Check interval to 1 minute.
  5. Set Expected HTTP status to 200.
  6. Click Save.

The root path serves the web dashboard — a 200 confirms both the HTTP server and the Python process are alive.


Step 2: Monitor the Code Completion Endpoint

POST /v1/completions is the endpoint IDE extensions poll on every keystroke pause. Latency and availability here directly determine whether developers experience Refact.ai as fast and reliable. Monitor it independently from the root path — endpoint failures may not surface at the dashboard level.

  1. Click Add MonitorHTTP / HTTPS.
  2. Enter:
    http://your-host:8008/v1/completions
    
  3. Set Method to POST.
  4. Under Request headers, add:
    Content-Type: application/json
    
  5. Under Request body, enter a minimal completion request:
    {
      "model": "@refact-code",
      "prompt": "def fibonacci(n):\n    ",
      "max_tokens": 16,
      "temperature": 0.1
    }
    
  6. Set Expected HTTP status to 200.
  7. Set Check interval to 2 minutes.
  8. Click Save.

This exercises the full completion path — request routing, model inference, and response serialization.


Step 3: Monitor the Chat Completions Endpoint

Refact's chat API (/v1/chat/completions) powers the conversational code assistance panel in IDEs. It may use a different model than the completion endpoint and can fail independently — for example, if a chat-specific model runs out of VRAM while the completion model continues running.

  1. Click Add MonitorHTTP / HTTPS.
  2. Enter:
    http://your-host:8008/v1/chat/completions
    
  3. Set Method to POST.
  4. Under Request body, enter:
    {
      "model": "@refact-chat",
      "messages": [
        {"role": "user", "content": "Write a hello world function in Python."}
      ],
      "max_tokens": 32
    }
    
  5. Set Expected HTTP status to 200.
  6. Set Check interval to 5 minutes.
  7. Click Save.

Step 4: Monitor the Web Dashboard

The Refact web dashboard (GET http://your-host:8008/) is where team admins manage users, model selection, API keys, and view productivity analytics. Dashboard downtime — even when the API continues working — blocks team management and onboarding.

In Step 1 you already added an HTTP monitor for the root path. Verify its Response must contain is set to detect dashboard content:

  1. Open the monitor from Step 1.
  2. Under Response body must contain, enter: Refact (a fragment that appears in the dashboard HTML).
  3. Click Save.

This catches cases where the server returns 200 but the dashboard renders an error page or blank body.


Step 5: GPU and Model Inference Heartbeat

Refact uses its own inference engine for supported models. GPU memory pressure, CUDA errors, or a model that fails to activate silently cause completion requests to queue indefinitely or return empty responses.

  1. In Vigilmon, click Add MonitorCron Heartbeat.
  2. Set Expected ping interval to 5 minutes.
  3. Copy the heartbeat URL.

Create check_refact_gpu.sh on the Refact host:

#!/bin/bash
REFACT_URL="${REFACT_URL:-http://localhost:8008}"

# 1. Check GPU availability
GPU_NAME=$(nvidia-smi --query-gpu=name --format=csv,noheader 2>/dev/null | head -1)
if [ -z "$GPU_NAME" ]; then
  echo "GPU unavailable"
  exit 1
fi

# 2. Check VRAM headroom (alert if <512MB free)
VRAM_FREE=$(nvidia-smi --query-gpu=memory.free --format=csv,noheader,nounits | head -1 | tr -d ' ')
if [ "$VRAM_FREE" -lt 512 ]; then
  echo "VRAM critically low: ${VRAM_FREE}MB free"
  exit 1
fi

# 3. Check a completion request succeeds within 3s
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" --max-time 3 \
  -X POST "$REFACT_URL/v1/completions" \
  -H "Content-Type: application/json" \
  -d '{"model":"@refact-code","prompt":"x = ","max_tokens":4}')

if [ "$HTTP_STATUS" = "200" ]; then
  curl -s "https://vigilmon.online/heartbeat/YOUR_GPU_HEARTBEAT_ID"
else
  echo "Completion probe failed: HTTP $HTTP_STATUS"
fi

Schedule every 5 minutes:

*/5 * * * * /path/to/check_refact_gpu.sh

Step 6: Monitor the Usage Analytics Pipeline

Refact tracks completion acceptance and rejection rates to calculate the team's AI productivity metrics. This data is written to a local SQLite or PostgreSQL database. If the analytics write pipeline breaks — disk full, database lock, or process crash — the dashboard shows stale data and the value of Refact's productivity reporting is lost.

  1. In Vigilmon, click Add MonitorCron Heartbeat.
  2. Set Expected ping interval to 30 minutes.
  3. Copy the heartbeat URL.

Create check_refact_analytics.sh:

#!/bin/bash
REFACT_DATA="${REFACT_DATA_DIR:-/var/lib/refact}"

# Check analytics database is accessible and recently written
DB_FILE="$REFACT_DATA/stats.sqlite"  # adjust path for your installation
if [ ! -f "$DB_FILE" ]; then
  echo "Analytics database not found: $DB_FILE"
  exit 1
fi

# Verify DB was modified in the last 60 minutes (if there's active usage)
LAST_MODIFIED=$(stat -c %Y "$DB_FILE" 2>/dev/null || stat -f %m "$DB_FILE")
NOW=$(date +%s)
AGE_MINUTES=$(( (NOW - LAST_MODIFIED) / 60 ))

# Only alert on stale DB if it's a business day working hour (simplistic check)
HOUR=$(date +%H)
if [ "$AGE_MINUTES" -gt 60 ] && [ "$HOUR" -gt 8 ] && [ "$HOUR" -lt 18 ]; then
  echo "Analytics DB stale: last modified ${AGE_MINUTES} minutes ago"
  exit 1
fi

# Check disk space on analytics volume
AVAIL_MB=$(df -m "$REFACT_DATA" | awk 'NR==2{print $4}')
[ "$AVAIL_MB" -gt 500 ] || { echo "Low disk on analytics volume: ${AVAIL_MB}MB"; exit 1; }

curl -s "https://vigilmon.online/heartbeat/YOUR_ANALYTICS_HEARTBEAT_ID"

Schedule every 30 minutes.


Step 7: Monitor Team Authentication

Refact's API key authentication gate controls which IDE extensions can connect. If the auth service fails — process crash, corrupted config, or an upstream dependency issue — all IDE connections are rejected. New developers can't set up their extensions and existing users may lose completions after session expiry.

  1. Click Add MonitorHTTP / HTTPS.
  2. Enter the Refact API info endpoint (used by IDE extensions to verify the server and their key):
    http://your-host:8008/v1/caps
    
  3. Set Method to GET.
  4. Set Expected HTTP status to 200.
  5. Optionally, set Response must contain to code_completion_default_model to verify the server config is fully initialized.
  6. Set Check interval to 5 minutes.
  7. Click Save.

The /v1/caps endpoint is the first thing IDE extensions call when connecting — it returns server capabilities, available models, and validates API key auth. Monitoring it covers both server health and auth service health in a single probe.


Step 8: SSL Certificate Monitoring

If Refact is served behind nginx, Caddy, or another reverse proxy with TLS, monitor certificate expiry to prevent IDE extensions from rejecting connections due to an expired or invalid certificate.

  1. Open the Refact server HTTP monitor from Step 1.
  2. Enable Monitor SSL certificate.
  3. Set Alert when certificate expires in less than 21 days.
  4. Click Save.

Step 9: Configure Alert Channels

  1. Go to Alert Channels in Vigilmon → Add → Slack, email, Discord, or webhook.
  2. Assign the alert channel to all Refact monitors.
  3. Tune thresholds:
    • Server process (Step 1): 2 consecutive failures — one blip may be a Python GC pause.
    • Completion endpoint (Step 2): 1 consecutive failure — developer impact is immediate.
    • Chat endpoint (Step 3): 2 consecutive failures — less time-sensitive than inline completion.
    • GPU / analytics heartbeats: default missed-interval alert.
  4. For teams in business hours, set the completions monitor to page on-call immediately on a single failure.

Summary

| Monitor | Type | URL / Target | Interval | |---------|------|-------------|----------| | Refact server process | HTTP | http://host:8008/ | 1 min | | Code completion API | HTTP POST | /v1/completions | 2 min | | Chat completions API | HTTP POST | /v1/chat/completions | 5 min | | Web dashboard content | HTTP (response check) | http://host:8008/ | 1 min | | Server caps / auth | HTTP GET | /v1/caps | 5 min | | GPU health + inference | Heartbeat | probe script → Vigilmon | 5 min | | Analytics pipeline | Heartbeat | probe script → Vigilmon | 30 min | | SSL certificate | SSL (on HTTP monitor) | reverse proxy domain | — |

Refact.ai is your team's private GitHub Copilot — when it works, developers experience it as an invisible productivity multiplier. When it doesn't, the silence is obvious within minutes. With Vigilmon covering every layer — process, API endpoints, GPU health, analytics, and TLS — you catch and fix problems before they become a team-wide productivity gap.

Get started for free at vigilmon.online.

Monitor your app with Vigilmon

Free plan — 5 monitors, no credit card required. Up and running in 60 seconds.

Start free →