Side project

Ops Monitoring & Batch Engine

Runs server batch jobs from database definitions and gathers metrics, SSH logins, and job history into one console. Failures are summarized into a morning report instead of night-time alerts.

Period
2026.02 — 2026.05
Role
Plan · Design · Build · Ship · Improve · solo
Stack
Next.js 16, Prisma, node-cron, systemd, Docker, Recharts

Process

  1. Plan

    Server jobs were failing silently; defined what “noticed” should mean.

  2. Design

    Job definitions in the database; one morning summary instead of night alerts.

  3. Build

    systemd runner, Next.js console and worker, SSO from the admin app.

  4. Ship

    A preflight checker validates every job’s command path before rollout; changed services redeploy automatically.

  5. Improve

    Hunted down timeouts, orphaned runs, and a log-rotation blind spot.

System diagram 8 components · 7 connections Play the flow and trace each connection

Overview

A batch engine under systemd reads a jobs table every 15 seconds, schedules with node-cron, and writes job logs. A Next.js console runs a background worker: metrics every 15 seconds, job sync every 60, SSH-login checks every 20. Metrics are kept 7 days.

Why I built it

Jobs scattered across crontabs fail with nobody noticing. With definitions in the database, the runner, the ops screen, and the daily report read the same source.

System

Commands must match an allowlist pattern—interpreter, script, arguments, no shell metacharacters—and the runner and the path checker share one module so they cannot diverge. Output is truncated at 60,000 characters; the timeout is 30 minutes.

The console signs in through SSO: the admin app issues a short JWT ticket and the console sets a 30-minute session cookie. Machine endpoints use their own API keys; login signals use a separate key because they reveal who logged in and when.

See this in the system diagram

Alerting

Instant failure alerts are off by default. One job sent 15 alerts a day for three weeks and nobody read them; a 09:00 summary found it. A 3 a.m. alert has no reader.

SSH alerts filter out routine deploy logins—about 155 a day—so an unusual one is not buried.

Stack

Next.js 16, React 19, Prisma 6, jose, Recharts, three.js, node-cron, mysql2, systemd, Docker.

Notes

Hard parts: a 5-minute timeout silently killed jobs at exactly 300 seconds; one job never succeeded in two months. Orphaned RUNNING rows sat for nine days—now reaped on boot and after 360 minutes. A repository restructure broke 49 jobs at once and went unnoticed for three days, which led to a preflight checker. The manual-run API was narrowed to the internal network. A single-file bind mount kept the old inode after log rotation, so the SSH check stayed green for ten days while blind; it is now a directory mount with a 6-hour staleness check.

What held: silent failures surface as one line in a morning report, and the runner, console, and report share one job definition.