Dev Server

Background daemon management for long-running services — daemons.json fields and crash recovery.

Dev Servers (daemons) manage long-running background processes — development servers, watchers, local services. Nebflow starts them, keeps them alive, and surfaces their status in the client.

Configuration lives in ~/.nebflow/daemons.json:

{
  "daemons": [
    {
      "id": "website-dev",
      "name": "Website Dev",
      "command": "npm run dev",
      "cwd": "~/projects/nebflow-website",
      "env": { "NODE_ENV": "development" },
      "autoStart": true,
      "restartOnExit": true,
      "port": 3000
    }
  ]
}

Configuration Fields

FieldTypeRequiredDefaultDescription
idstringYes—Unique daemon id
namestringYes—Display name in the client UI
commandstring | string[]Yes—Command to run (a plain string is split on whitespace)
cwdstringNo—Working directory
envmapNo{}Extra environment variables
autoStartboolNofalseStart when Nebflow starts
restartOnExitboolNofalseRestart when the process exits
portintNo—Port the service listens on (enables health checks and open-in-browser)

Crash Recovery

All optional and backward compatible — a minimal id/name/command entry gets sensible defaults:

FieldDefaultDescription
restartBackoffSec2Delay before the first auto-restart; doubles per attempt, capped at 60s
restartMaxAttempts5Give up after this many consecutive crash restarts (crash-loop protection)
restartStableWindowSec60A run longer than this resets the consecutive-crash counter — a daemon that crashes once a day is never falsely exhausted
healthCheckSec15Periodically TCP-probes port; a live process with a closed port is treated as crashed. 0 disables the active health check (only process-exit detection remains)

Status

A daemon reports one of four states — stopped, running, crashed, starting — plus runtime details: pid, start time, exit code, and recent output. When a port is configured, an independent reachability probe reports whether the port accepts TCP connections, so an externally-started server (not managed by Nebflow) still shows as reachable.

Managing Daemons

The client settings panel has a Dev Servers (开发服务器) section where you can add entries and start/stop daemons without editing the JSON by hand.