Run many lanes on one machine
Use this when you keep many lanes on one machine and want the unused ones to cost little without stalling the ones that work in the background.
::example{slug="showcase-many-services"}
Change when lanes slow down and freeze
Section titled “Change when lanes slow down and freeze”An unused lane is throttled, then frozen, and the next request brings it back (Throttling and freezing). Set both times in the user config; 0s turns either off.
lanes: throttle_after: 10m freeze_after: 1hlanesWhere lane data folders (lane.data_path) live on this machine, and how long a lane may sit without activity before devlanes throttles or freezes it.
lanes.throttle_afterAfter this long without activity, a lane's processes run at background priority: lower CPU priority, and efficiency cores on machines that have them. They keep serving requests. Activity is a request through the proxy, a new connection to one of the lane's ports, the lane's services using CPU, or a devlanes command on the lane; any of it restores normal priority and restarts the timer. macOS and Windows only; Linux has no throttling, so lanes there stay at normal priority until freeze_after. When both are set above 0s, it must be shorter than freeze_after. A running service with services.<name>.keep_awake: true keeps its whole lane at normal priority. Defaults to 5m; 0s turns throttling off. The daemon reads it when it starts.
lanes.freeze_afterAfter this long without activity, devlanes freezes a lane: it suspends every process of the lane and pauses the lane's own containers. Shared infra is never paused. Ports and process state are kept, so a frozen lane still counts as running. A request through the proxy, a new connection to one of the lane's ports, or a devlanes command on the lane resumes a frozen lane and restarts the timer. The lane's services using CPU keep a running lane from freezing, but cannot resume a frozen one, since its processes are suspended. A request through the proxy resumes the lane at once and then goes through; a direct connection to a port is noticed within about half a second. When both are set above 0s, it must be longer than throttle_after (5m unless set). A running service with services.<name>.keep_awake: true keeps its whole lane awake. Defaults to 15m; 0s turns freezing off. The daemon reads it when it starts.
Keep a lane awake
Section titled “Keep a lane awake”A worker or a queue consumer works without requests, so mark it, and its lane is never throttled or frozen while it runs.
services: worker: run: node worker.mjs keep_awake: trueservicesLong-running processes of each lane, started together after infrastructure, setup and lane.start tasks. Each service gets its own port as PORT and, with hosts, HTTPS hostnames. A service that exits shows as failed and is not restarted.
services.<name>A long-running process started with the lane, such as a dev server or a worker. Each service gets its own port from the lane's block (PORT, ${{ self.port }}); devlanes stops it with the lane and never restarts it when it exits. A service needs run or run_script, directly or through extends.
services.<name>.runCommand that starts the service. A string runs with /bin/sh -c, so pipes, && and multi-line scripts work; a list is an argv run directly without a shell. It starts in the project file's directory unless cwd is set. devlanes runs it exactly as written, so it cannot be combined with preset; prefer run_script when the command is a script in a project file. Exactly one of run and run_script is required after templates are applied. In a list, an item that is one ${{ }} expression giving a number or true/false becomes its text, such as --port followed by ${{ self.port }}.
services.<name>.keep_awakeWhile this service runs, devlanes never throttles or freezes its lane, whatever lanes.throttle_after and lanes.freeze_after in the user config say. Set it on workers, queue consumers, schedulers and tunnels that do work without inbound requests, which a frozen lane would otherwise stall. One such service keeps the whole lane awake. An expression is evaluated for each lane, such as ${{ lane.index == 0 }} to keep only the main lane awake. Defaults to false.
Pace large starts
Section titled “Pace large starts”Every start goes through a start gate that limits how many services start at once across all lanes. A fixed window keeps that number constant.
startup: mode: fixed max: 4startupHow many services may be starting at the same time across all lanes and projects, so a large start does not overload the machine. Defaults to one start per CPU core.
Config referencestartup.modeadaptive, fixed or all; default adaptive. A starting service holds its slot until its ready check (tcp, http, log or cmd) passes, it fails, or slot_timeout passes; one without a check (ready: started) holds it until it settles (settle_cpu).
startup.maxMost services starting at once: the constant window in fixed mode and the ceiling in adaptive mode. Defaults to the number of CPU cores; all ignores it.
Keep disk use in check
Section titled “Keep disk use in check”Logs share one age and size limit across all lanes. Data folders and the volumes of a lane’s own containers stay until the lane is cleaned, as Remove lanes shows.
logs: retention: days: 3 max_size: 2GiBlogsHow much service output devlanes keeps under ~/.devlanes/logs, by age and total size.
logs.retentionAge and total-size limits for stored service output; a cleanup every 10 minutes deletes the oldest output past either one. Defaults to 7 days and 5GiB.
logs.retention.daysDelete output older than this many days, along with its index entries in the database; defaults to 7 and must be at least 1. The newest log file of each stopped service is kept.
Config referencelogs.retention.max_sizeTotal size of stored output across all projects and lanes; defaults to 5GiB and must be above zero. Over it, the oldest output goes first wherever it is, but each stopped service's newest file and up to 1 MiB of a running service's current file are kept.
Apply the changes
Section titled “Apply the changes”The daemon reads the user config when it starts, so restart it from a shell that has your services’ variables.
$ devlanes daemon restartIf a lane never freezes
Section titled “If a lane never freezes”A browser tab whose dev client keeps sending over a WebSocket counts as use, and so does a busy watcher. Close the tab, or see Throttling and freezing for what else counts.