garage44.eu/jeroen/midas

logclone: git clone https://garage44.eu/jeroen/midas.git

.. /docs/node.md

raw

Setting up a node

A node is set up by the owner of the build machine, on that machine. One command does it, and the same command updates it later.

What you get

The node registers itself with the hub; nobody copies keys around.

Before you start

Check the tunnel

The hub is 10.44.0.1; your machine has its own address on the same network (the one the node was added with). Four checks, in order — each one's failure is a different fault:

sudo wg show                              # 1. "latest handshake" under two minutes old
ip route get 10.44.0.1                    # 2. must say "dev wg0", not your LAN's interface
ping -c3 10.44.0.1                        # 3. answers
curl -m5 http://10.44.0.1:4791/v1/health  # 4. {"ok":true,…}
fails atwhat it meansfix
1, handshake hours oldyour public address changed and nothing sent since, or UDP 51820 out is blockedthe keepalive above, then ping once to wake it
1, Secrets were required from nmcli … upthe key is in your keyring, not with the connectionthe NetworkManager step above
1, a peer with no endpoint or allowed ips; 3 says Required key not availablethe connection knows the hub's key and nothing else, so nothing is routed to it — nmcli still says activatedsudo nmcli connection modify wg0 wireguard.peers "<hub's public key> endpoint=<hub host>:51820 allowed-ips=10.44.0.0/24 persistent-keepalive=25", then sudo nmcli connection up wg0
2, a route via wlan0/eth0the tunnel is up but nothing routes into it (an address shown with noprefixroute)sudo ip route add 10.44.0.0/24 dev wg0 now; +ipv4.routes above for good
3 or 4 with 1 and 2 finethe hub's sideask the workspace's operator; on the hub sudo wg show names your peer and when it last heard from you

connection refused from setup usually means the address after --hub is your own machine's, not the hub's.

1. Build and install midas

Build it yourself, from a commit you have read — that binary is the only midas code that ever runs on your machine:

git clone <the midas repository> && cd midas
cargo build --release

The page the hub serves is not needed here; a build without Bun is fine. On SteamOS, build inside a distrobox (the distrobox shares your home) and run setup outside it, where sudo reaches the system:

distrobox enter arch
sudo pacman -S --needed rustup git && rustup default stable
cd ~/midas && cargo build --release
exit

2. Set it up

sudo target/release/midas setup box-1 --hub 10.44.0.1:4791

box-1 stands for your node's name as the hub knows it, and 10.44.0.1:4791 is the hub, never your own machine's address. The hub's address is needed the first time only. Setup copies the binary it runs from to /var/lib/midas/bin/midas — where only root can change it, because root runs it; writable on SteamOS, whose /usr is not — and runs from there on.

Setup also makes midas a command: /etc/profile.d/midas.sh puts /var/lib/midas/bin on every login shell's PATH (log in again, or . /etc/profile.d/midas.sh in the shell you have), and a link /usr/local/bin/midas lets sudo midas … find it. Where /usr is read-only (SteamOS) there is no link, and setup says so: with sudo, keep giving the full path there.

Options, all remembered:

optiondefault
--memory10g (Mac: 24g)
--cpus6
--gpu/dev/dri/renderD128, or none
--mount HOST_DIR:/CONTAINER_DIR— (read-only; e.g. an Android NDK)
--usermidas-node

It ends with registered with the hub. The hub's warmer then builds the node up, and it joins the pool with its first heartbeat.

GPU machines, optional: to cap the GPU's own memory as well (an AMD handheld's shared memory is guarded either way), let systemd hand the dmem controller to users — a file /etc/systemd/system/user@.service.d/dmem.conf with [Service] and DelegateControllers=cpu memory pids dmem — reboot, and run setup again. midas check says whether the cap is in force.

A render node without a GPU: QEMU's 3D virtio-gpu (what a guest's Vulkan goes through, Venus) needs a GL context, which in a container only a render node gives. A machine with no GPU (the VPS) gets one from the kernel's vgem: echo vgem | sudo tee /etc/modules-load.d/vgem.conf, sudo modprobe vgem, the node's user in the render group (sudo usermod -aG render midas-node), and the render node open to all, since sshd hands a node's session to build with that user's own groups only: a file /etc/udev/rules.d/70-vgem-render.rules with SUBSYSTEM=="drm", KERNEL=="renderD*", KERNELS=="vgem", MODE="0666" (vgem only hands out buffers; many distributions leave every render node so). Then setup with --gpu /dev/dri/renderD128. Rendering itself stays on the CPU (lavapipe): this gives QEMU its context, not the node a GPU, so the hub's gpu flag for it stays off.

3. Check it

midas node status
node box-1 on this machine (user midas-node, hub 10.44.0.1:4791)
  ✓ running
  ✓ firewall in force
  ✓ heartbeat 16s ago
  · midas f027df28 · load 1.2 · 120 GB free · warm at 3dac67f6
  · free

More in usage.md.

Updating

Pull, build and install a newer midas (step 1), then run setup again — no options needed:

cd ~/midas && git pull && git log -1      # read what you are about to run
cargo build --release --target x86_64-unknown-linux-musl
sudo install -D -m 755 target/x86_64-unknown-linux-musl/release/midas /var/lib/midas/bin/midas
sudo /var/lib/midas/bin/midas setup box-1

On SteamOS the build line runs inside the distrobox, as in step 1: distrobox enter arch -- sh -c 'cd ~/midas && cargo build --release --target x86_64-unknown-linux-musl'.

From your own machine, all at once

midas update does the above for every build machine, one after another, from the machine you sit at: this checkout's commits sent to each as a git bundle (a machine's own git key often works only from a login with its ssh agent), built there (distrobox included), installed and set up with your sudo. The hub only says which machines and nodes there are; how to reach each is your config, in ~/.config/midas/hub.env:

MIDAS_MACHINES=deck=deck@192.168.1.50 box=me@box.lan   # machine=ssh target, as its owner
MIDAS_SRC=~/code/midas                                   # the checkout it installs

The machine you run it on needs no entry: its nodes are set up there, so it builds in place. A machine with no checkout of midas — the hub's own, which has no toolchain — gets the binary another machine in MIDAS_MACHINES built for its architecture at the same commit (the deck's, for x86_64; machines go in name order, so one updated in the same run counts), and runs setup from a copy in /tmp the way deploy.sh does, without installing it: the hub's own /usr/local/bin/midas stays as it was. Where sudo needs no password (the vps's ubuntu), none is asked for. Then:

midas update              # every machine
midas update deck         # only those named
midas update --src DIR    # another checkout

A machine in neither is skipped, and one with a held node is left for later (exit 75), waited for (--wait: its nodes are drained, their holders told, and the update starts once they let go), or updated anyway (--force cuts the holder off); the nodes being updated are drained while it runs. The end says which machines were updated, skipped, held or failed. The machines only need ~/midas and cargo, not a midas that has update; where the installed one predates it, run the checkout's own: cargo run --release -- update.

Run without a terminal — by an agent — sudo asks for each password in a dialog on your screen (macOS's own; elsewhere set SUDO_ASKPASS): this machine's through sudo -A with midas as its askpass, a remote machine's through ssh's stdin to its one sudo -S. Neither goes into an argument list or into the output the agent reads. The dialog names the machine and the nodes; type a password only into one you expected.

The node keeps its checkout and warm build directory. It restarts, so do it when midas node status says free. Afterwards midas --version and the midas … on status's fourth line name the build you installed.

Setup is also what makes later features real on your machine: a newer midas does nothing until it is installed and set up again. A machine still on a build from before setup made midas a command has no /etc/profile.d/midas.sh, for instance.

Power

Setup also starts midas node power on the machine itself — not in the node: a VM sees no power sensor, and a stopped node's machine still draws. Once a minute it sends the hub the chip's power in watts, from

That is the chip, not the wall socket: memory, disk, fans and the power supply's loss come on top. A machine with none of these (a cloud VM) has nothing to send, and the service ends at once. It runs a copy of midas at /var/lib/midas/power/midas, put there by each setup. The hub takes a sample only from an address one of its nodes has, and keeps them for good; the page's Workspace and midas power show them. Removing the machine's last node stops it.

Asleep while nobody uses it (Macs)

A Mac node free for an hour — no lease, no ssh session, no bot, not drained, nobody waiting for a node — has its VM shut down, and started again as soon as somebody waits for a node it could serve, or it is drained for an update. The power job above does it, asking the hub every 15 s; the guest is asked to shut down (tart run's SIGUSR2), never stopped hard, and its build directory stays on disk. Measured on the mini in November 2026: an idle macOS guest keeps about a core busy (audiomxd, configd), 17 W all night for two, and a sound device taken away with --no-audio changed nothing.

Waking takes the VM's boot and its first heartbeat, a minute or two, which the first build after a quiet hour waits for. midas status and the page say asleep, not offline, and midas check does not count it as a problem. A machine whose power job stops asking has its nodes left awake. Linux nodes are not stopped.

Removing

sudo /var/lib/midas/bin/midas setup box-1 --remove

stops the node and removes its firewall. Its user and data stay until you delete them (sudo userdel -r midas-node).

Renaming

A node's name is a label; what it is, is the uuid the hub gave it, and its data — the volume at /work, or a Mac node's VM — is named once, when it is first set up, and never again from the name (storage in its settings file). So a rename moves nothing. At the hub, once nobody holds the node:

midas nodes rename box-1 box-2

then on the machine:

sudo /var/lib/midas/bin/midas setup box-2

Setup finds box-1 here by its uuid (or, for a node set up before uuids, by the hub listing box-1 as a former name), stops it, and starts box-2 on the same data: the checkout, the warm build directory, its ssh host key — which the hub's known hosts already trust on that port — and its bots' secret. It refuses while the hub still knows box-1 too: that is two nodes, not one renamed. A node set up before storage was recorded keeps its data under the name it had then (midas-node-box-1-work); the settings file says so.

Bot credentials

Usually set at the hub: midas bot token <node|gpu|machine> from anywhere with a caller key (usage.md), which works for a Mac node too. What follows is the way that keeps the token on this machine instead.

An agent may run a bot on your node (a program it talks to over MCP — usage.md), and a bot usually needs a credential of its own: for Cartopolis, an access token you create there for it. You give it here, on your machine; it never goes to the hub:

sudo /var/lib/midas/bin/midas bot setup box-1 --env CARTO_TOKEN

It asks for the value with echo off (--stdin reads one line from a pipe instead) and stores it as CARTO_TOKEN=… in bot.env, beside the node's node.env — readable only by the node's build user, the user bots run as, which sees it as /config/bot.env. Every bot started on the node from then on has it in its environment. The name is remembered: to change the value, run it again without --env. --remove deletes it. Not on Mac nodes yet.

Anything running as build in the node can read a running bot's environment — the agent holding it, and the hub's operator key — so give a token only what the bot needs, and revoke it where you made it if in doubt.

When something is wrong

symptomlook at
midas node status says not runningsudo midas node logs
running, but no heartbeatCheck the tunnel
setup: asking the hub … timed out or refusedCheck the tunnel
down after a rebootWireGuard at boot (above)
setup says the address is not on this machineWireGuard is not up, or the hub has another address for the node
the hub logs warm_failed … REMOTE HOST IDENTIFICATION HAS CHANGEDsomething other than this node answers on its ssh port — see below

A second copy of the node

Before the node had its own user, install.sh ran it as the machine's owner, from ~/.config/containers/systemd/midas-node-<node>.container. A machine set up then and again since has two nodes of one name. Whichever starts first at boot holds the ssh port; when that is the old one, it serves a host key the hub has never seen (the warmer refuses it, rightly), its git key is not registered, and the real node never starts. midas node status can still say ✓ running, because both containers have the same name. To tell:

ss -ltnp | grep :2223                     # which user's process holds the port
ls ~/.config/containers/systemd/          # as the owner: should hold no midas-node-*

Retire the old one as the owner (no sudo), then start the real one:

mkdir -p ~/midas-old && mv ~/.config/containers/systemd/midas-node-box-1.container ~/midas-old/
systemctl --user daemon-reload && systemctl --user stop midas-node-box-1
sudo /var/lib/midas/bin/midas node restart

Leave the hub's known_hosts alone: the key it has is the real node's. The old copy's volume stays until podman volume rm midas-node-box-1-work.