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

| Field | Type | Required | Default | Description | |-------|------|----------|---------|-------------| | id | string | Yes | — | Unique daemon id | | name | string | Yes | — | Display name in the client UI | | command | string | string[] | Yes | — | Command to run (a plain string is split on whitespace) | | cwd | string | No | — | Working directory | | env | map | No | {} | Extra environment variables | | autoStart | bool | No | false | Start when Nebflow starts | | restartOnExit | bool | No | false | Restart when the process exits | | port | int | No | — | 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:

| Field | Default | Description | |-------|---------|-------------| | restartBackoffSec | 2 | Delay before the first auto-restart; doubles per attempt, capped at 60s | | restartMaxAttempts | 5 | Give up after this many consecutive crash restarts (crash-loop protection) | | restartStableWindowSec | 60 | A run longer than this resets the consecutive-crash counter — a daemon that crashes once a day is never falsely exhausted | | healthCheckSec | 15 | Periodically 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.