Day-to-day running of a RigForge worker: the command reference, managing the service, reading logs, upgrading, and troubleshooting.
Most days you touch a handful of these. Each is a single command. The full command reference is below.
| I want to… | Command | What happens |
|---|---|---|
| Change a setting (pool, rig name, TLS, failover) | edit config.json, then sudo ./rigforge.sh apply |
Regenerates the live config and restarts. No rebuild. A miner that is deliberately stopped stays stopped. |
| Upgrade to a new release | git fetch --tags && git checkout vX.Y.Z && sudo ./rigforge.sh upgrade |
Regenerates the live config, reinstalls the units and restarts (and re-tunes); rebuilds XMRig for a changed pin, a missing/nonzero compiled-minimum marker, or a failed binary checksum. See the note below. |
| Run a live tune now | sudo ./rigforge.sh tune --now |
One live pass against the running miner; keeps the best prefetch mode if it wins. Linux only. |
| Check the worker is healthy | sudo ./rigforge.sh doctor |
HugePages, MSR, governor, service, pool connection, with a fix hint for anything off. |
| Watch it mining | ./rigforge.sh logs |
Live logs, no root needed; Ctrl-C stops following (the miner keeps running). |
| Stop / start / restart | sudo ./rigforge.sh stop · start · restart |
Control the miner service. |
| Quick correctness and speed check | sudo ./rigforge.sh bench |
Offline benchmark; requires a verified hash and reports H/s. |
| Confirm BIOS stability | sudo ./rigforge.sh stress --minutes 30 |
Linux offline load test; reports pass/fail and peak temperature. |
| Save config + tuning | ./rigforge.sh backup |
Snapshots the only hard-to-recreate state to ./backups. No root needed. |
On macOS, drop the
sudo(the privileged steps are Linux-only) and run./rigforge.sh restartafterapplyto pick up changes.doctorand the live re-tunes (tune --now,tune --live) are Linux-only. See Running on macOS.
The complete surface. Most days you only need the handful in Common tasks above; the rest are here for completeness.
Keep rigforge.sh together with its bundled util/ directory. Run it as sudo ./rigforge.sh [command]. Optional: set
"add_to_path": true in config.json and setup installs a rigforge command on your PATH, so you can
run sudo rigforge [command] from any directory; uninstall removes it.
Not every verb needs root — the design, in four lines:
setup/upgrade/apply/uninstalland the service verbs (start/stop/restart/enable/disable) callsudoinline for each privileged step — run them withsudo(or be ready for the inline password prompts).tune,bios, andstressre-run themselves undersudoautomatically (interactive terminals only, so a script never hangs on a password prompt).autotuneuses inlinesudo systemctlcalls instead.status,logs,backup, andrestorenever need root — you shouldn't type a password just to look at your own rig.doctorworks without root, but gives its deepest checks (MSR register read-back, RAM layout) as root.
On Linux, setup and upgrade refuse to install the root-run units when a non-root user could change
the code those units run (#783). They check rigforge.sh, the util/ and systemd/ directories and every
file in them, .git/config and the git hooks in a git checkout (root runs git there for remote
upgrades), and every directory from the code tree up to /, both as given and with symlinks resolved. Each path must be owned by root, writable by
no group other than root's, and not writable by every user. A path that cannot be inspected counts as a
refusal, and the message names the first path that fails. config.json is operator data, not code, and is
not checked. A root-owned tree passes silently.
--no-root-guardaccepts the tree anyway and prints a warning. It also records the allowance in the root-owned/etc/rigforge-root-guard(it names the tree), so later remote upgrades through the control path, which pass no flags, accept the same tree with a warning. An allowance file that a non-root user could write, or one that names another tree, is ignored.uninstallremoves it.- An install that predates the guard (a git checkout with the miner unit installed and no allowance file)
is allowed once with a loud warning and the allowance is recorded, so its remote upgrades keep working.
A packaged tree (with a
.rigforge-packagemarker) is never allowed this way. - The guard runs from the tree it checks, so it catches a tree left writable by mistake. It cannot stop a
user who already writes the tree before the first guarded run, because that user can change the guard
itself or create a
.gitdirectory to qualify for the one-time allowance. - To close the gap instead, make the tree root-owned:
sudo chown -R root:root <tree> && sudo chmod -R go-w <tree>, then delete/etc/rigforge-root-guard. Afterwards, update the checkout withsudo git.
On a tree that passes the guard, setup, upgrade, apply, tune, bios and restore keep the worker
folder (data/worker by default: the miner binary and its checksum, the tune files, the markers and the log)
owned by root and writable by no one else, instead of handing it to the operator. Every folder above the
worker folder, as given and with links resolved, must pass the same test; otherwise the folder is handed to
the operator as before. When root takes the folder back, it removes every symbolic link inside it and names
them in a warning. If the miner binary was not root-owned, setup or upgrade rebuilds it (in the same
run, or in the next one when another command took the folder back). When root cannot take the folder back,
setup, upgrade and restore stop. config.json stays the operator's, and with miner_user set the
miner's config and log are still handed to that user. On such a tree config-backups/ stays root-owned too
(a link there is followed, and the folders above its target must pass as well), and each snapshot in it is
handed to the operator, so cp config-backups/<file> config.json still works without sudo. Run setup,
upgrade and apply on such a tree with sudo, because the operator account can no longer write the
worker folder.
| Command | What it does |
|---|---|
setup (default) |
Provision the worker: dependencies, build, hardware + kernel tuning, and the service. Idempotent and safe to re-run; skips the recompile when the pinned XMRig is already built. |
upgrade |
Redeploy this RigForge release onto the rig: regenerate the live XMRig config, reinstall the systemd units, hand the files to you (and to miner_user, if set) so the miner can read its rebuilt tree, restart so both are in effect, and re-tune if periodic autotune is enabled (the fastest knobs can shift between versions). The compile is the conditional part — XMRig is rebuilt when the pinned version/commit changed, the compiled-minimum marker is missing or nonzero, or the binary checksum fails. A miner you had deliberately stopped is left stopped, and the regenerated config and unit take effect at your next start (#413). --check just reports whether a newer RigForge release exists (on-demand GitHub query, always exits 0). |
apply |
Re-read config.json, regenerate the live XMRig config, and restart, without recompiling. A miner that is deliberately stopped — a watchdog thermal hold, or your own stop — is left stopped, and picks up the new config at its next start. The fast path after editing config.json. On Linux it also reconciles the periodic-autotune timer with config (so changing the autotune target takes effect) and reports it (efficiency / performance / disabled), then asks the running miner whether a live pool connection came up — and warns when none did (a bad pools[0].url otherwise mines nothing while looking applied, #343). Warn only, never a failure: the pool may be legitimately down at apply time. apply exits non-zero when the miner restart is rejected (#630; the control path then rolls the change back instead of reporting it applied), and when the watchdog units could not be re-rendered (#395) — that one is a real failure, because the cadence the rig is running would otherwise diverge from config.json silently. |
uninstall |
Remove the service and revert all system changes (fstab, limits, modules, GRUB) and the worker build/logs. Leaves config.json. Prompts first; add --yes to skip. |
doctor |
Read-only health check (run with sudo for the deepest checks). Critical findings (counted as issues): the service is active, the miner has a live pool connection (read from the miner's own local API — a running miner with no connection is not mining, #343; with the service stopped, one TCP dial of pools[0] stands in for a direct pool; a proxied connection cannot be verified until mining starts), HugePages are reserved, kernel lockdown isn't blocking MSR writes (read from /sys/kernel/security/lockdown — active lockdown means the MSR mod cannot apply, and msr.allow_writes=on can't override it), the msr module is loaded, and the MSR mod actually applied, confirmed from XMRig's log and, as root, an rdmsr register read-back (see MSR mod verification). Advisory findings (hints, not failures): the live algorithm when it differs from rx/0, an unreachable configured SOCKS proxy for an enabled pool (a successful TCP dial stays quiet and does not prove SOCKS/Tor health), CPU governor, 1 GB HugePages, HugePages 100%-backed (from the XMRig log), hashrate-capping hardware RigForge can't fix but you can (single-channel or slow RAM via dmidecode, and a power/boost-capped CPU clock), per-thread placement (the core each CPU thread runs on, read from the miner's /2/backends; an explicit unavailable reason when the miner is stopped or the API is silent), and BIOS/firmware recommendations (board/BIOS context, plus enable XMP/EXPO/DOCP or SMT when they're off; manual BIOS changes RigForge can't make from the OS). Prints an actionable hint for anything off. Also binary tamper evidence (#141): the on-disk xmrig is compared against the SHA-256 recorded at compile time — a deliberate rebuild refreshes the record, anything else warns and counts as an issue. When the writable control path is enabled, it's also a counted issue: doctor checks rigforge-control is active and its /status endpoint answers (#278), staying silent when control is disabled. Exits non-zero when critical issues are found (cron-friendly, matching Pithead's status). |
bench |
Verify an offline benchmark and report H/s (BENCH=10M for a longer run). --submit opts into publishing and verifying an online benchmark; --verify ID checks a submitted result. See Self-tests. |
stress [--minutes N] |
Linux stability test after firmware changes; default 30 minutes, range 1–1440. Stops the miner, samples temperature under offline load, and restores its prior state. See Self-tests. |
tune |
The single command for tuning. A bare tune measures the fastest CPU-specific knobs (prefetch, cpu.yield, thread count) offline and keeps them, an optional, one-time step. Live variants: --now / --short (a quick prefetch re-tune against the running miner, the run a live tune now path), --now --long (a full live search of every knob, = --live), --confirm (A/B-check the winner live). Plus --efficiency / --perf, --history, --clear. See Tuning. |
bios |
Guided, resumable walk-through of the BIOS/UEFI changes for your hardware — the settings tune can't reach from the OS (Secure Boot when kernel lockdown is blocking the MSR mod, memory profile XMP/EXPO/DOCP, SMT, PBO/Eco-Mode, NUMA-per-socket NPS on EPYC; --efficiency picks the low-power set). Detects the current firmware state via the same probes doctor uses, hands you a board-specific checklist one item at a time, saves the pending items, and on the next run re-verifies which changes actually took. RigForge never writes BIOS itself; plan for console access (keyboard/KVM) for the reboot-into-BIOS step. Linux-only. See Guided BIOS tuning. |
autotune |
The scheduled live tuner. You normally don't type it; tune --now is the friendlier spelling for an on-demand run, and the periodic schedule is what this verb is really for: set "autotune": "performance" (raw H/s) or "autotune": "efficiency" (hashrate-per-watt) in config.json and setup installs a systemd timer (also re-tuned on upgrade). Conservative: it keeps a change only if it beats the baseline by a margin, else rolls back. An overlap with a running tune/autotune sweep is skipped with status 0 (the skip reason is logged), so the timer can't double-sweep and upgrade still completes. Linux-only. See Live auto-tuning. |
watchdog |
One health check per run — the scheduled recovery verb, like autotune. You normally don't type it; set "watchdog": "enabled" in config.json and setup installs a timer that runs it every watchdog_interval_min minutes: two consecutive checks seeing 0 H/s or a dead API restart the wedged miner, and with max_temp_c set it stops the miner above that temperature (starting it again 5 °C below). Linux-only. See Watchdog. |
backup |
Snapshot config.json + the tuning files into a timestamped tar.gz under ./backups. See Backup & restore. |
restore |
Restore config.json + tuning from a backup archive: restore [-y] <archive>. Prompts before overwriting. |
status |
One-glance live summary from the worker API (hashrate, pool, uptime, accepted/rejected shares, and the live algorithm when it differs from rx/0 — one fetch, no sudo), then the systemd service status. Miner stopped or API off: a single "worker API not reachable" line and the platform block as before. |
logs |
Follow the live service logs (journalctl -f). |
start / stop / restart |
Start, stop, or restart the miner service. (up / down are aliases for start / stop.) |
enable / disable |
Start the service on boot, or not. |
version (-v, --version) |
Print the RigForge version. |
help (-h, --help) |
Show usage. |
setup is the default, so sudo ./rigforge.sh with no argument provisions (or re-provisions) the
worker.
Both doctor and status also report whether the source config and tune overlay match
the last recorded generation. Changed sources produce an advisory warning with the apply
command; a missing stamp on an older install is informational. These rows do not change either
command's exit status. See generated config provenance.
The staged build that setup and upgrade compile first never records or clears this stamp.
The service verbs (status/logs/start/stop/restart/enable/disable) work on Linux
and macOS: systemd on Linux, a launchd login agent on macOS (enable/disable). doctor,
tune --live, and autotune are Linux-only. See Running on macOS.
After setup (and the reboot), confirm everything took effect:
sudo ./rigforge.sh doctorThis catches the common silent failures: HugePages not reserved (needs a reboot) or the MSR mod blocked by Secure Boot. See Troubleshooting.
On a fresh install
setupenables the service but doesn't start it until you reboot (HugePages aren't reserved before then), so adoctorrun betweensetupand the reboot will report "service is not active". That's expected; it starts automatically after you reboot.
Use doctor --json when another program needs the health result:
sudo ./rigforge.sh doctor --jsonIt writes one JSON object to standard output and keeps the human report on standard error. The object has this contract:
versionis the RigForge version andexitis the command's exit status.summarycontains integerok,warn,fail, andinfocounts.checksis an array of{id, status, message}objects.statusis one of the four summary keys.
Treat exit as the health authority instead of deriving success from row statuses. A critical finding
still has status warn; it also makes exit non-zero. The fail count is reserved and is currently
zero. On a non-Linux host, the Linux-only check is skipped, checks is empty, and both the process and
reported exit remain zero.
Check IDs are stable for automation, but row availability depends on the worker's configuration and
available probes. An ID may repeat: socks-proxy, for example, can produce one row for each configured
proxy. tor-socks5 is one row: info when tor_socks5 is unset on a plain host, ok when its port (or the
appliance-rig local Tor default the key defaults to) accepts a TCP connection, warn when it does not or
the value is invalid. Messages are operator-facing text and are not a stable interface. Consumers should therefore
select rows by id and status, allow repeats, and use the summary and exit fields for the overall
result.
RigForge auto-configures the hashrate-critical settings, so a freshly-deployed worker already runs well.
tune is an optional, one-time step that measures the handful of knobs whose best value is genuinely
CPU-specific (the RandomX prefetch mode, cpu.yield, the thread count) and keeps the fastest:
sudo ./rigforge.sh tune # measure the fastest knobs for this CPU — thorough, so it takes a while
sudo ./rigforge.sh apply # regenerate the config with them and restartTune once, run for months. The result is saved to a separate overlay (
tune-overrides.json), so yourconfig.jsonis never touched, and it's kept for the life of the rig. After anupgradebumps XMRig, RigForge reminds you to re-tune (the fastest knobs can shift between versions).
tune optimizes for whatever your autotune config is set
to, so if autotune is "efficiency", a plain tune measures hashrate-per-watt, matching what the
scheduled run does. Override per-run with --perf or --efficiency. It announces the target at the
start, e.g. Optimization target: efficiency (hashrate-per-watt). Run it without sudo and it re-runs
itself with sudo for you.
See what's tuned, and what the periodic auto-tuner has been doing, at any time:
./rigforge.sh tune --history # applied knobs + the last full run + recent auto-tune decisionsUseful variants (all optional):
| Command | What it does |
|---|---|
tune --now (or --short) |
Run a live tune now: a quick convergent pass against the running miner that keeps the best prefetch mode if it wins. The everyday live re-tune; Linux only. |
tune --now --long |
A full live sweep of every knob (prefetch, cpu.yield, thread count, 1G-pages) against the running miner, not just the prefetch mode. Thorough but slower; measures your running pool's real conditions/algorithm. Alias: tune --live. Linux only. |
tune --efficiency / --perf |
Force the optimization target, hashrate-per-watt vs raw speed, overriding the autotune config default for this run (efficiency needs a power source). |
tune --confirm |
A/B-check the winner on the live miner and keep it only if it genuinely beats the previous config. Linux only. |
tune --history |
Show the current tuning, the last full run, and recent auto-tune decisions. |
tune --clear |
Discard all tuning and return to the auto defaults. |
The search internals, every tunable knob, the full list of TUNE_* environment variables, and the
power/efficiency and reservation-aware details are all in
How It Works -> Measured tuning.
sudo ./rigforge.sh bios walks the detect → guide → reboot → re-verify loop for the firmware
settings with the biggest RandomX impact: Secure Boot when kernel lockdown is blocking the MSR mod
(it leads the checklist — the cheapest change, and it gates the ~5–15% MSR mod outright; whether to
make it is the operator's call, bios just makes the cost visible), the memory profile
(XMP/EXPO/DOCP), SMT, the CPU power/boost posture (--efficiency swaps the boost item for
Eco-Mode + Curve Optimizer), and — on EPYC — NUMA nodes per socket (NPS4, so RandomX gets
quadrant-local memory). It reads
the same probes doctor reports on, so the two never disagree; pending items are saved to
rigforge-bios.json (included in backup/restore) and the next bios run re-checks exactly
those items against fresh probes — an item only counts as applied when its OS-visible fingerprint
flips (lockdown reading none, memory running at rated speed, SMT on, loaded clock above the boost
threshold). The CPU
boost item needs the miner running to measure; with it stopped, bios says so and keeps the item
pending rather than guessing. After everything took, run stress to confirm stability, then
tune --live to measure the changed hardware.
bench runs XMRig's offline RandomX benchmark with its known all-zero seed and built-in reference
hash. RigForge reads XMRig's own verification verdict, including the different reference for a
single hashing thread. A mismatch, missing verdict, failed process, or fatal allocation/configuration
error exits nonzero as a correctness failure. Speed alone cannot pass. Offline tune rejects the
whole candidate if any measured iteration fails verification; live tuning still measures pool work.
bench --submit explicitly opts into network access and publishes the benchmark's hardware and
performance information. RigForge waits for the submission ID, then runs XMRig's --verify=ID
against that result before reporting success. bench --verify ID repeats this online check.
Plain bench, offline tune, and stress do not submit anything. The last benchmark's seed, hash,
verdict and optional ID are saved in rigforge-bench.json under the worker directory and included
in support-bundle. Missing or invalid records are reported as skipped.
After BIOS changes, run sudo ./rigforge.sh stress (30 minutes), or set --minutes N.
It pauses active watchdog/autotune timers, refuses to interrupt an already-running scheduled check,
stops an active miner, and runs XMRig's continuous offline stress mode. The test samples the same
CPU temperature source as the watchdog and reports peak temperature (or unavailable). A process
failure, failure to hash, or temperature above configured max_temp_c fails the test.
The run asks XMRig for a speed report every 10 seconds, and a failed run prints the last lines of XMRig's output.
Normal completion, errors and interrupt signals restore the previously active miner and timers.
An over-temperature failure leaves the miner stopped with a watchdog thermal hold; the watchdog
can resume it after it cools below the existing recovery threshold. If the watchdog is disabled,
let the rig cool and run watchdog manually before resuming. Stress applies no new thermal control
or firmware changes. Run it without other manual tuning or service-management commands.
Run one pass on demand any time with sudo ./rigforge.sh tune --now. It sweeps the prefetch modes
against your running miner and keeps the best if it beats the current setting by a margin. For a thorough
pass that sweeps every knob live (threads, yield, 1G-pages, not just prefetch), use tune --now --long
(the live equivalent of a bare tune). No scheduling needed; either is a quick way to re-tune live after
a BIOS, RAM, or cooling change. tune --now is the friendly name for the autotune engine; the
standalone autotune verb still works and is what the scheduled timer below runs.
Live sweeps apply each candidate to the running miner as they measure it. If a sweep is interrupted
(Ctrl+C, a dropped SSH session) or errors out mid-run, RigForge restores the tuning that was in place
before the sweep and restarts the miner on it — a half-measured candidate is never left running or
saved to tune-overrides.json. A sweep killed harder than that (SIGKILL, OOM, power loss) is covered
too: the pre-sweep tuning is snapshotted in tune-overrides-pre.json, and the next tune or
autotune restores it before reading its baseline; tune --clear, and restore when the backup
carries tuning, drop the snapshot.
Sweeps also serialize: only one tune/autotune runs at a time — a second manual tune refuses with a
nonzero exit while one is in progress, and an overlapping autotune (timer run included) skips with
status 0.
For a hands-off schedule, set autotune in config.json to a target and re-run setup. RigForge
installs a systemd timer that periodically optimizes the prefetch mode against your live miner:
autotune |
What the scheduled run optimizes for |
|---|---|
"disabled" (default) |
Nothing. No timer is installed. |
"performance" |
Raw hashrate (H/s). |
"efficiency" |
Hashrate-per-watt (H/s/W), for power-cost-, heat-, or PSU-limited rigs. Needs a power source (built-in RAPL, or a TUNE_POWER_CMD for a smart plug / IPMI); without one it falls back to performance with a warning. |
Legacy booleans still work: true → performance, false → disabled. The chosen target is baked
into the systemd unit at setup, so the scheduled run optimizes for what you picked, and tune --history
shows it.
Each run converges in one pass (~minutes). It reads the current hashrate from the miner's API (median of
a few samples, plus average watts when the target is efficiency), then sweeps every prefetch mode
(applying each, restarting, and re-measuring over a warmup window) and adopts the best by the target's
metric, but only if it beats the baseline by a margin (else it keeps the current mode). A single run
settles on the best prefetch mode; you don't wait days. The change is merged on top of any offline tune
result, so your tuned thread count and cpu.yield are preserved.
When it re-tunes: once the prefetch mode converges it's stable, so re-tuning is event-driven, not a blind daily loop that churns the miner to re-confirm a result that rarely changes.
- After an
upgrade, the real trigger. The fastest knobs can shift between XMRig versions, so once a rebuild finishes (and the new build is live) RigForge re-tunes it automatically. - A monthly safety-net timer. The default cadence is monthly, to catch slow drift (thermal, ambient
temperature, fan/dust). Change it with
AUTOTUNE_ONCALENDAR(any systemd calendar spec) beforesetup, e.g.AUTOTUNE_ONCALENDAR=weekly sudo ./rigforge.sh setup.
Review the schedule, the next run, and recent decisions any time with rigforge tune --history (or
journalctl -u rigforge-autotune).
Auto-tune only touches the prefetch mode, the knob most worth re-checking live. For a definitive,
one-time sweep of every knob, run the offline tune above. Linux only.
The MSR "RandomX boost" (writing the CPU's prefetcher MSRs) is one of the biggest levers, worth ~10–15%,
so doctor verifies it actually took effect, not just that the msr module loaded:
- Kernel lockdown first: before any MSR probe,
doctorreads/sys/kernel/security/lockdown— active lockdown (integrityorconfidentiality, which distro kernels enable automatically under UEFI Secure Boot) denies every/dev/cpu/*/msrwrite before themsr.allow_writesfilter is even consulted, so it is flagged as the cause rather than letting the probes below fail mysteriously. - From XMRig's log (always): the
msr register values for "<preset>" preset have been set successfullyline confirms XMRig wrote the per-family preset (e.g.ryzen_19h_zen4). AFAILEDline is flagged — attributed to lockdown when lockdown is active, otherwise tomsr.allow_writes=onor a hypervisor. - Register read-back via
rdmsr(rundoctoras root, withmsr-toolsinstalled;setupinstalls it):doctorreads the prefetcher registers back and checks they hold the preset's values, catching a write a hypervisor or kernel lockdown silently dropped even though XMRig reported success. Run without root, withoutrdmsr, or with themsrmodule unloaded, this step is skipped with an advisory, never a false alarm; the log check above still confirms the write.
With miner_user set (see configuration), xmrig runs unprivileged and cannot
write MSRs itself: randomx.wrmsr is disabled in the generated config and RigForge applies the same
per-family preset root-side instead (rigforge.sh msr-apply, an internal verb like api-refresh —
the sister API's 15 s data-refresh the systemd timer drives — run as a privileged ExecStartPre= of the
service). doctor's read-back check verifies the root-side write the same way, and also confirms the
unit actually runs as the configured user.
You almost never need to tune the MSR preset. XMRig auto-selects the right per-family preset, and that's
optimal on the vast majority of CPUs. The knob exists for the rare case where a non-default preset (or
disabling the mod) wins on unusual silicon: set TUNE_WRMSR="true false" (or a preset number) to sweep
randomx.wrmsr alongside the other knobs. It's applied per-bench (no reboot) and pinned only if it
actually wins.
Restart=always in the miner's unit only covers a dead process. The failure mode it can't see:
XMRig wedges — process alive, 0 H/s, HTTP API unresponsive — and systemd reports active (running)
while the rig mines nothing. The watchdog covers that gap, plus an optional thermal cutoff for the
"failed case fan in July" scenario.
Each timer tick runs one check (journalctl -u rigforge-watchdog.service shows every decision):
- Wedge recovery (2-strike rule). The local worker API (
127.0.0.1:8080/2/summary, with theACCESS_TOKENBearer header when one is set) is unreachable or reports 0 H/s → one strike. Two consecutive strikes (~2 ticks, unambiguous) restart the miner; a single blip — a restart-in-progress, the dataset re-initializing — never does. Any healthy check resets the count. - Thermal cutoff (only with
max_temp_cset). Above the cutoff the miner is stopped and a hold marker written after the stop succeeds; later checks start it again once the temperature drops belowmax_temp_c - 5(the 5 °C hysteresis is fixed — enough to outlast the post-restart heat-up without stranding the miner). An unreadable sensor skips the thermal check entirely: a missing sensor must not stop a healthy miner. A localapply, or a config change arriving over the control path, does not break the hold — it regenerates the config and leaves the miner stopped for the watchdog to start. The sensor isthermal_zone0when the board exposes one, else the CPU hwmon (k10temp/coretemp). Before setting a cutoff, check the live reading on your board (THERMAL_ZONEoverrides the path) — k10temp reports Tctl, which runs high by design (a loaded EPYC sits near 90 °C Tctl in perfectly normal operation), so a damage-avoidance cutoff belongs well above the everyday reading, not near it. Editingmax_temp_ctakes effect on the next tick — the watchdog re-readsconfig.jsonevery run, noapplyneeded. While the hold lasts, a miner started by other means (by hand,setup, or a tuning sweep's re-apply) is stopped again on the next tick; a tuning sweep's re-apply leaves a held miner stopped. The cutoff also runs when the rest ofconfig.jsonfails validation: ifmax_temp_citself still reads as a whole number 40-110 and the miner is active above it, the watchdog stops it, writes the hold marker and still exits with the config error. While the config fails validation, only that cutoff runs: no hold is lifted, and a held miner that was started again is stopped only while it is abovemax_temp_c. WhenHOME_DIRitself is rejected, the stop writes no hold marker and says so; start the miner by hand once the config is fixed. Aconfig.jsonthat is not valid JSON, or an invalidmax_temp_c, gives no cutoff until it is fixed. A failed stop is logged and retried on later ticks while the miner remains active and above the cutoff. A failed recovery start is logged and retains the hold for later retries, including whenmax_temp_cis removed; only a successful start clears the hold. On the shared-host profile a start is additionally refused while the loaded unit is out of profile (for exampleshared_hostadded toconfig.jsonbeforeapplyran): the tick that wants to start — the hold lift, or the second wedge strike's restart — logs the guard'srun applyerror and keeps the hold. Stopping is never guarded, so the thermal cutoff stops a hot miner even while the unit is out of profile. - A miner that's not running is left alone — dead-process recovery is systemd's job.
Disable it with "watchdog": "disabled" (or removing the key) + apply; the units are removed
cleanly. uninstall removes them too.
If config.json holds a combination RigForge refuses, DONATION above 0 while Tor is in effect, the watchdog still runs its thermal stop and wedge recovery against the miner as it stands. It logs the conflict on every tick, and the sister feed shows it as health.config_conflict. setup, upgrade and apply refuse until DONATION is 0 (#762).
RigForge runs XMRig as a systemd service named xmrig:
sudo systemctl status xmrig # service status
sudo systemctl stop xmrig # stop the miner
sudo systemctl start xmrig # start the miner
sudo systemctl restart xmrig # restart (e.g. after a config change)RigForge also wraps these so you don't have to remember the unit name:
./rigforge.sh status / logs (no root needed) and sudo ./rigforge.sh start / stop / restart.
The service is enabled at install, so it starts automatically on boot (and after the post-setup reboot).
On macOS there is no systemd service. RigForge builds and configures XMRig but you run it yourself. See Running on macOS below.
macOS is best effort: Ubuntu 24.04 is the fully supported deployment platform, and on macOS most
of RigForge works while the degraded features are listed below (no CI coverage or bench for macOS). On macOS,
sudo ./rigforge.sh still does the core work: it installs dependencies (via Homebrew), compiles XMRig
from source, and writes a tuned config.json. What it doesn't do is the Linux-only system integration:
- No kernel tuning, and no reboot. macOS doesn't expose HugePages or MSRs, so the HugePages, MSR,
hugetlbfs, and GRUB steps are skipped. The generated config turns those knobs off accordingly (huge-pages,1gb-pages,wrmsr/rdmsrarefalse) and binds the API to IPv6::. Because the biggest RandomX levers (HugePages + MSR) are Linux-only, expect a lower hashrate than a tuned Linux box: fine for development, not for a production rig. - No systemd service / no auto-start on boot. There's no service to install, and the miner doesn't start
at boot.
setupdoesn't leave you to hand-roll a launch command, though. The samestart/stop/restart/status/logsverbs work on macOS too (see below); on macOS they manage XMRig as a background process tracked by a PID file under the worker root, instead of via systemd.
setup doesn't start the miner on macOS, so launch it yourself when ready, with the same command you'd
use on Linux:
./rigforge.sh start # background the miner (records a PID file)
./rigforge.sh status # is it running?
./rigforge.sh logs # follow the live log (Ctrl-C to stop following)
./rigforge.sh stop # stop it
./rigforge.sh restart # stop + startNo sudo is needed on macOS (the HugePages/MSR steps that need root are Linux-only). start runs the
binary from the worker build dir with the generated config; the log is at <WORKER_ROOT>/xmrig.log
(data/worker/xmrig.log by default).
To have the miner start on its own, enable installs a per-user launchd LaunchAgent, macOS's analogue of
the systemd boot-start:
./rigforge.sh enable # start the miner now and at every login
./rigforge.sh disable # remove the login agentThe agent lives at ~/Library/LaunchAgents/com.rigforge.xmrig.plist, restarts the miner if it crashes,
and starts it at each login. Once enabled, launchd owns the miner: start / stop / restart /
status then drive the agent (via launchctl) instead of an ad-hoc process, so you never end up with
two miners. enable starts it immediately too, unlike systemd's enable. A headless, always-on Mac
would want a system LaunchDaemon instead of a per-user agent; that's beyond this dev/light-use target,
so run as a LaunchDaemon by hand if you need it.
Edit config.json, regenerate the live config, then restart:
./rigforge.sh apply # regenerates the config (no sudo on macOS)
./rigforge.sh restart # pick up the new configdoctor, uninstall, tune --live, autotune, watchdog, bios, and tune --now need systemd / Linux and aren't available on macOS.
Everything else works anywhere: setup, apply, bench, the offline tune, backup / restore,
version, and the full service surface start / stop / restart / status / logs / enable /
disable (which uses systemd on Linux and a launchd login agent on macOS).
./rigforge.sh support-bundle (no root needed) collects what a maintainer needs — doctor output,
version, both configs (structurally redacted: token and pool password removed, pool user/wallet
masked to first-4…last-4), the five logging values in effect (xmrig-logging.json), a 500-line miner-log tail, tuning files, unit files, hardware basics, and
XMRig's hwloc topology (xmrig-topology.xml, from xmrig --export-topology, which XMRig writes next to its binary; RigForge moves it into the bundle and leaves nothing in the build directory. When the miner is not built, the flag is missing or the export fails, for example without hwloc or without write access to the build directory, the reason is listed under not_collected in manifest.json) —
into a mode-600 tarball next to the script. It never collects the journal, shell history, or
unredacted configs, and never uploads anything. Extract and review it before attaching to a
public issue.
Tab completion is opt-in and installs nothing by default:
# bash — per-user, or system-wide via the completions dir:
echo 'source <(rigforge completion bash)' >> ~/.bashrc
rigforge completion bash | sudo tee /etc/bash_completion.d/rigforge >/dev/null
# zsh (uses bashcompinit; printed as part of the script):
rigforge completion zsh >> ~/.zshrcOutput is colored only when stdout is a terminal; set NO_COLOR=1 to disable color everywhere
(no-color.org) — piped, captured, and journal output is always plain text.
sudo journalctl -u xmrig -f # live service logs- Log file: ordinary installs write
<WORKER_ROOT>/xmrig.log(e.g.data/worker/xmrig.log) and automatically compress and retain seven archives. Appliance mode omits this persistent file and uses the image-capped systemd journal instead. - Logging keys: on Linux RigForge sets
colors: false, so the log and journal carry no ANSI escapes, and keeps XMRig's 60 sprint-timeandhealth-print-time. Set any ofcolors,print-time,health-print-time,verboseandsyslogin thexmrigoverlay and runapply; the value survives restarts. On the appliance, where the journal is size-capped, a longer cadence such as"xmrig": {"print-time": 900, "health-print-time": 900}cuts journal churn (the watchdog reads/2/summary, not the console report). To debug a pool handshake or TLS failure, apply"xmrig": {"verbose": 1}and remove it afterwards.0disables a report line. - Build log: the XMRig compile output is captured to
<WORKER_ROOT>/build.log(e.g.data/worker/build.log) during setup, so a failed build is diagnosable after the fact. On any unexpected failure the script also names the step that failed and prints the last lines of the build log.
After editing config.json, apply it in one step:
sudo ./rigforge.sh applyapply re-reads config.json, regenerates the live XMRig config, and restarts the service, with no
recompile. Use it for a pool change, a new rig label, TLS, failover pools, or DONATION. Existing
builds need one upgrade to install the zero donation minimum; later reductions use apply. See
Configuration › Changing settings later.
A full setup re-run also regenerates the config and, on Linux, restarts the service if the generated
config changed or XMRig was rebuilt. An unchanged re-run leaves a running miner undisturbed;
a pending reboot defers startup until that reboot. Use apply for an edit without re-provisioning.
XMRig does not hot-reload edits to its generated config or save its own changes back to that file.
On macOS, apply regenerates the config but you restart the miner yourself; see
Running on macOS.
apply restarts a miner that is running. A miner that is deliberately stopped is left stopped:
the regenerated config and the re-rendered unit sit on disk and take effect the next time the miner
starts — your own sudo ./rigforge.sh start, or the watchdog's own tick once the temperature is back
under the cutoff. That covers both ways a rig is legitimately offline, the thermal
hold and a plain stop, and it needs no knowledge of which one you are in: apply
reads whether the miner is running, not why it isn't. Raising max_temp_c on a rig that is currently
held therefore does what you would expect — it changes the ceiling, and the watchdog decides when the
rig comes back, against the new one.
RigForge pins XMRig to a known version/commit. To move to a newer pinned build:
./rigforge.sh upgrade --check # optional: is there a newer RigForge release? (on-demand, no sudo)
git fetch --tags && git checkout vX.Y.Z # the release you want (your clone is pinned to a tag, so `git pull` does not apply)
sudo ./rigforge.sh upgrade # regenerate config, reinstall units, restart; rebuild when the pin, compiled minimum or checksum requires itupgrade --check compares your VERSION against the latest GitHub release and prints the upgrade
recipe if you're behind. It's the only command that queries GitHub's API, it runs exactly when you
type it (nothing is scheduled — see SECURITY.md), and it always exits 0, so it's
safe to call from your own scripts. With tor_socks5 set it
asks that proxy to resolve and reach GitHub, and an unreachable proxy ends in a warning, never a direct
connection. The same key carries the XMRig source clone and a remote upgrade's git fetch; the remote
upgrade refuses to start when the proxy does not answer or origin is not an https URL, and records
that as its failed reason.
Package installs. A .rigforge-package marker beside rigforge.sh (its value is apt or brew;
RIGFORGE_PACKAGE_MARKER points the lookup elsewhere) says the package manager owns the tree, as the
.rigforge-appliance marker does for an appliance. With it, upgrade --check still compares versions
through the tor_socks5-aware fetcher but prints sudo apt upgrade rigforge or brew upgrade rigforge
instead of git steps; control_upgrade and any tag upgrade refuse before running git and record that
command as the failed reason; setup and upgrade skip the dependency install and the add_to_path
symlink. Without the marker nothing changes.
upgrade skips the recompile when the pinned XMRig is already built with a zero minimum marker
and a valid binary checksum, so it's cheap to run — but it is
not a no-op: it regenerates the live config, reinstalls the systemd units and restarts, because a
RigForge release can change either of those without moving the XMRig pin. A plain
sudo ./rigforge.sh (setup) also picks up a changed pin, but upgrade is the explicit, restart-aware
path. If you've enabled periodic autotune, upgrade re-tunes the new build
automatically once it's live. The optimal prefetch mode can change between XMRig versions, so the upgrade
is the moment that actually warrants a re-tune (the monthly timer is just a slow safety net).
Pulled RigForge changes but not a new XMRig pin?
upgradeis still the command — regenerating the config and reinstalling the units is where RigForge's own changes land, and it restarts so they take effect. Kernel and hardware tuning is the one thing it does not touch. A release rarely changes it, but it does happen — #410 moved what RigForge proposes for the HugePages GRUB line — so if a pull did change it, run a fullsudo ./rigforge.sh setup.Earlier releases returned early here whenever the XMRig pin was unchanged — which was every published release pair — so an
upgraderegenerated nothing, reinstalled nothing and still reported success;applywas the workaround. Fixed in #413.
Old build artifacts are archived/pruned across runs, so repeated upgrades don't leak disk. A failed XMRig fetch, build or configuration step aborts the upgrade and leaves the live
xmrig/tree (binary and config) untouched. A swap interrupted mid-way is recovered by the nextsetuporupgrade.
When apt upgrade rigforge installs a newer version on a host that already has a
config.json, the package's postinst only writes /var/lib/rigforge/upgrade-pending and starts
the one-shot rigforge-upgrade.service with systemctl start --no-block; dpkg returns at once.
A first install, a reinstall of the same version and a host without a config queue nothing.
The one-shot runs rigforge package-upgrade, which is upgrade outside dpkg: it rebuilds XMRig
only when the pin, compiled minimum or checksum requires it, re-renders every unit, and restarts
the miner only after all of that succeeded, including the optional API and control units. It runs as root without SUDO_USER, so it takes the operator from the owner of config.json (which every setup and upgrade hands to the operator) and sets file ownership the way upgrade does. Follow it with journalctl -u rigforge-upgrade.
If it fails, the previous build keeps running, the marker stays, /var/lib/rigforge/upgrade-failed
records the failure, and both rigforge status and rigforge doctor report it. dpkg is never
failed by it. Retry with the one command sudo rigforge upgrade; a successful run clears the
marker. To defer upgrades, sudo apt-mark hold rigforge (undo with apt-mark unhold rigforge).
RigForge reads code from one directory and writes state to another. Both default to the directory holding rigforge.sh, so a git clone keeps everything in one tree and nothing changes unless you set a variable.
| Variable | Default | Holds |
|---|---|---|
RIGFORGE_LIB |
the directory of rigforge.sh |
rigforge.sh, util/ scripts, systemd/ unit templates, VERSION, RIGFORGE_REF, the .rigforge-package marker. Never written by a worker command, so it can be root-owned and read-only. |
RIGFORGE_STATE |
the same directory (RIGFORGE_HOME when set) |
config.json, the .rigforge-* markers and sidecars (appliance marker, config provenance, revision key), config-backups/, backups/, support tarballs and the default worker root data/worker. |
The apt package runs rigforge.sh with RIGFORGE_LIB=/usr/lib/rigforge and RIGFORGE_STATE=/var/lib/rigforge. A tree whose .rigforge-package marker reads apt uses those values whenever RIGFORGE_STATE is unset, so running /usr/lib/rigforge/rigforge.sh directly behaves like rigforge. There is no /etc/rigforge: config.json is state that setup creates, not a dpkg conffile, so the first-run wizard still runs on a fresh install and upgrades never prompt about it.
RIGFORGE_HOME is the older sandbox override: it sets the state directory and the template, VERSION and proposed-grub.sh lookups, while the util/ scripts still come from the directory of rigforge.sh. Set RIGFORGE_LIB and RIGFORGE_STATE instead; each wins over it. Rendered units take ExecStart and the server script from the lib directory and the config.json credential from the state directory. When either variable is set, the miner unit and the scheduled verb units (autotune, watchdog, api-refresh, control-apply, control-upgrade) and the shared-host runner carry it in their environment. Both values must be clean absolute paths (letters, digits, ., _, -, /), and as root RIGFORGE_LIB must be owned by root and not group- or world-writable; otherwise rigforge.sh refuses to start. The upgrade verb updates a git checkout in place, so it still needs a writable checkout.
A worker's expensive, hard-to-recreate state is small: your config.json and the tuning result
(tune-overrides.json, which can take hours to produce). The XMRig build and the system tuning are
regenerated by setup, so they're not worth saving. backup snapshots that state into a portable
archive:
./rigforge.sh backup # -> ./backups/rigforge-backup-YYYYMMDD-HHMMSS.tar.gz (no root needed)The archive is owner-only (chmod 600) and includes config.json, the tuning files, and a small
manifest (RigForge version + source host). Back up after first-run setup and again after each tune.
restore puts it back. Point it at an archive:
./rigforge.sh restore ./backups/rigforge-backup-20260101-120000.tar.gz # prompts; -y to skip
sudo ./rigforge.sh setup # rebuild + apply (or 'apply' if XMRig is already built)Restore overwrites config.json and the tuning on the current machine (so it prompts first), then tells
you to run setup/apply to put the restored config into effect. Before it overwrites, restore saves the
current config to config-backups/, the same folder the control path uses, and the newest 20 files are
kept. Restore therefore needs to be able to write next to config.json.
- Recover from data loss. A wiped disk would otherwise mean re-doing setup and re-tuning. With a backup
it's
restore+setup. If the rig kept its worker folder under a customHOME_DIR, run first-run setup with thatHOME_DIRbefore restoring, because restore keeps the running install's worker folder. - Roll a tune across a fleet. Tune one machine,
backup, thenrestoreon each identical machine; they all get the same config and the same tuning without re-running the slow search.
NOTE: Tuning is CPU-specific. Only reuse
tune-overrides.jsonbetween identical CPUs. On different hardware, restore the config but re-runtune(ortune --clearto drop the inherited tuning). Restore never takesHOME_DIRfrom the archive. The restoredconfig.jsonkeeps the running install'sHOME_DIR, and the tuning files go to that install's worker folder. When there is no liveconfig.json, or itsHOME_DIRis unusable, the key is dropped and the default worker folder is used. When the archive names aHOME_DIRthat maps to a different worker folder, restore prints a warning naming it and the folder used.
After setup (and the reboot, on Linux), confirm the optimizations applied.
HugePages:
grep Huge /proc/meminfoHugePages_Total, HugePages_Free, and Hugepagesize should be non-zero and match what setup
configured.
MSR (Model-Specific Registers):
grep -i msr <WORKER_ROOT>/xmrig.logIf you see MSR errors, see Troubleshooting below.
| Symptom | Likely cause & fix |
|---|---|
| Setup fails during the build | The script names the step that failed and tails the build log. Read the full error in <WORKER_ROOT>/build.log (e.g. data/worker/build.log). Common causes: a build dependency you declined to install (re-run and accept), or too little RAM during compilation (the build already caps parallelism by RAM; add swap on very low-memory hosts). Re-run sudo ./rigforge.sh once resolved; it resumes without redoing finished work. |
| MSR errors in the log | Kernel lockdown is denying the MSR writes (distro kernels enable lockdown automatically under UEFI Secure Boot). msr.allow_writes=on cannot override it — the kernel checks lockdown before that filter. doctor reads /sys/kernel/security/lockdown and says which level is active; the fix is disabling Secure Boot in BIOS/UEFI (bios gives the board-specific path), then rebooting. |
doctor: "MSR registers don't match the preset" |
XMRig's log says the write succeeded but the read-back disagrees: something silently dropped it. When kernel lockdown is active, doctor names it as the cause (see the lockdown item it prints first); otherwise a hypervisor is the usual culprit — common on VMs/cloud instances, run RigForge on bare metal. msr.allow_writes=on (RigForge sets this) only matters when lockdown is not enforced. |
doctor: "couldn't read the MSRs via rdmsr" |
The msr module isn't loaded (or doctor wasn't run as root). Run sudo ./rigforge.sh doctor; if it persists, sudo modprobe msr and check /etc/modules-load.d/msr.conf — a missing module is a modprobe/packaging problem, not Secure Boot (the in-tree signed module loads fine under it). This is advisory; XMRig's log already confirms the write. |
HugePages_Total is 0 |
The kernel tuning needs a reboot to take effect (GRUB change). Reboot, then re-check grep Huge /proc/meminfo. |
| HugePages still 0 after reboot | Not enough contiguous memory was reservable, or another tool changed GRUB. Re-run sudo ./rigforge.sh; it merges its parameters into GRUB_CMDLINE_LINUX_DEFAULT and keeps the others. If that line is not one plain double-quoted value (single quotes, a trailing comment, an escaped double quote, or more than one such line), RigForge leaves the file untouched and prints the parameters to add by hand: edit /etc/default/grub, then sudo update-grub. |
| Low hashrate / few threads | RandomX is L3-bound (~2 MB per thread). A CPU with little L3 runs fewer effective threads; this is expected. See Hardware › L3 cache. |
| No AVX2 | RandomX still runs but slower. AVX2 is strongly recommended; there's no fix beyond different hardware. |
| Dashboard can't read the worker | The API is open (no token) by default, so first check the worker is reachable from the stack host on :8080. If you set an ACCESS_TOKEN, the dashboard must send the same token (workers.api_auth: token + workers.api_token, or name if the token is the rig name). See Pithead Integration › Troubleshooting. |
| Pool unreachable | Confirm the worker can reach its pool URL (firewall, DHCP/static IP). LAN pools use plain Stratum without Tor. For an .onion pool, check pools[].socks5 and that your Tor SOCKS proxy is running; doctor warns when the configured proxy cannot accept a TCP connection. |
- Getting Started — first-run setup and verification.
- Configuration — config keys and how the XMRig config is generated.
- Pithead Integration — the dashboard contract.
Set "api": "enabled" in config.json and run sudo ./rigforge.sh apply. The rig then serves a
second read-only HTTP endpoint (default :8081, keys api_port/api_bind) with everything the
:8080 XMRig API has plus the data only RigForge knows: applied tune knobs and the last tune
run (/tune), hashrate-per-watt from RAPL, the doctor probes — HugePages, MSR state, governor,
RAM channels/speeds, memory-profile and SMT state, throttling — the watchdog's armed/thermal state,
the effective writable config (config, pool secrets masked; #253), a config revision +
last-change provenance (config_meta; #254), and the last control-path outcome (control,
{change_id, status, reason} or null; #346) — as JSON (/health, or nested under
rigforge in /1/summary and /2/summary). It follows XMRig's own architecture: one tiny
persistent server (python3 stdlib, ~10 MB idle) ships pre-computed bytes, so a request costs
microseconds and cannot touch mining performance; a systemd timer schedules a refresh every 15
seconds off the request path. Refreshes use normal CPU priority (Nice=0) to share CPU time with
the miner when publishing control changes; disk I/O stays at idle priority and
the cached HTTP server retains Nice=19. The queued thermal and separate pools replay tests check direct-feed
freshness and exact-ID publication, capturing timer-driven helper timings under the control
replay fixture. They preserve the service policy and normal feed publication. The timer uses an independent wall-clock cadence,
so a failed refresh or a unit reinstall cannot strand the feed without a future run. Summary and
health responses carry generated_at in UTC; doctor reports its age and the timer's next/last
trigger, and warns once the payload is over a minute old. The same
ACCESS_TOKEN posture applies (open when unset, Bearer required when set), it is read-only by
construction (GET only), and when XMRig is down the RigForge data still serves with an
"xmrig_api": "unreachable" marker — which is exactly when the health data matters. Linux-only;
"api": "disabled" + apply removes the units cleanly. Systemd loads both network servers'
Python entrypoints and config as private credentials before dropping to DynamicUser, so a checkout
beneath a 0750 home works without relaxing home permissions. Setup and apply fail if the enabled
sister API cannot be installed, primed, or confirmed active and listening. The listener check accepts
a warming-up 503 or authentication-required 401; it does not require a live miner. Apply completes
its other reconciles before returning the sister-API failure. The feed additionally carries
rigforge.os_version (the appliance image's version; null on standalone rigs) and
rigforge.rig_id (the rig_id config label; null when unset, never invented), and
authenticated reads additionally carry rigforge.identity — display hints (mac and
board_uuid truncated, cpu_model verbatim) for telling clones and moved hardware apart —
which an unauthenticated route never serves and which never authenticates anything
(rig_id included). See Pithead integration.
The sister API above is read-only by design. The control path is its separate, opt-in, writable
counterpart (#236): it lets a Pithead stack apply config changes through RigForge so
config.json stays the single source of truth (the producer for pithead's Worker Inspect). It is
off by default and deliberately paranoid, because it is the one endpoint that accepts writes.
Control has no read side of its own: enabling it (#507) also enables the sister API above, so
Pithead can confirm an applied change through the enriched feed — there's nothing to set for api
by hand. That implication only runs local -> remote; api is not a key the control path can write,
so a Pithead stack can never flip it on by itself.
Turn it on by setting three things in config.json and running sudo ./rigforge.sh apply:
"control": "enabled",
"ACCESS_TOKEN": "<a shared secret>", // required — a writable API with no token is refused
"api_allow_from": "10.0.0.5" // required — the stack host/CIDR that may write; refused if unsetBoth ACCESS_TOKEN and api_allow_from are mandatory when control is enabled — setup/apply
hard-errors without them, because a writable path with no token or no pinned source is an open
remote config write. The control port (default :8082, control_port/control_bind) is scoped by
the same nftables rule as the read API, so only the stack host and loopback can reach it. The receiver
is stopped before its firewall is loaded and started only after the load succeeds, and its unit loads
the rule file before every start (including at boot) and refuses to start if nft rejects it, so a
rejected firewall load leaves the writable port stopped, never open.
How a change flows:
- The stack
POSTs a JSON object of changed keys to:8082/applywith the Bearer token. The receiver records the acceptedchange_idaspending(with anaccepted_atstamp) the instant it stages the change — before the oneshot below has even started — so polling it while step 2/3 run below returnspending, not the 404 an unknown id gets (#344). Onlypools,DONATION,autotune,watchdog,watchdog_interval_min, andmax_temp_care writable; identity/trust/path keys (ACCESS_TOKEN,miner_user,HOME_DIR, theapi_*andcontrol_*keys) are operator-only and rejected. The remote path is a tuning channel, not a safety-removal one: a change that would disable thewatchdogor unset / out-of-bandmax_temp_c(a rig's thermal protection) is refused with400— remove thermal protection locally withrigforge.shif that's really intended (#257). The receiver validates the shape, stages the change, and returns202 Acceptedwith a change id. It holds no privilege and never touches the miner, so a write cannot cost hashrate. Apply and upgrade share a 20-request durable queue; a full queue returns retryable503without staging another file. The token is write-capable and travels in cleartext HTTP — isolate the mining LAN (#256; see Security). - A path-triggered root oneshot takes the shared privileged-control lock and picks up the staged change.
In appliance mode, a request containing
poolsis rejected as a whole withappliance-pools-read-only, before any snapshot or config write. Change the pool in Pithead configuration (rig.jsonfor the rig role), which owns the appliance pool across boots. Other allowlisted tuning keys remain writable; ordinary rigs still accept pool edits. The receiver returns202for staging, so callers must poll the change ID for this terminal rejection. Otherwise, the oneshot snapshots the currentconfig.jsontoconfig-backups/config-<UTC-stamp>.json, merges only the allowlisted keys, and re-validates the result with the same rulesapplyuses. An invalid change is rejected and nothing is written. - A valid change is written durably (temp file,
fsync, atomic rename) and applied. If the final directory sync fails after the rename made it visible, the receiver still returns202with the change id and a durability warning so callers poll status rather than duplicate the request. If that write cannot be completed — the mode cannot be pinned to0600, or the rename fails — the outcome is recorded asfailedand nothing is applied (#434). The rename lands inconfig.json's own directory, so it either replaces the file wholly or leaves it alone: the old config stays live, the miner is never restarted, and there is nothing to roll back. The change itself was valid, which is why this is not reported asrejected. The snapshot taken a moment earlier is discarded on this path (#438):config.jsonwas never replaced, so that file is a copy of the config still live and records no change to go back to, which is also why the status reportsbackup: nullfor this outcome and not a path. Changing onlywatchdog_interval_minand/ormax_temp_ctakes a restart-free fast path (#381): neither key ever reaches XMRig's generated config or its unit, so only the watchdog timer is reconciled and XMRig itself is left running — round-trip in about a second instead of the ~60s a full restart costs on a big-page host. Any other key (alone or mixed with those two) applies through the normalapplypath, which restarts XMRig — unless the rig is deliberately stopped, in which case it stays stopped and takes the change at its next start (#396), exactly as a localapplydoes. Both paths judge the result the same way: only a rig that was live and did not come back is a failure, so a thermal hold or a manual stop that predates the change is never mistaken for one it caused. If the miner does not come back to a live hashrate (full path) or the miner service is not found still running (fast path — a signal something else was already wrong, since neither key can cause that), the snapshot is restored and re-applied through the full path, and the outcome is recorded asrolled_back(orfailed, if the rollback snapshot itself could not be read back). A watchdog timer that could not be re-rendered — the unit files are unwritable, ordaemon-reloadfails — rolls the change back the same way (#395). The fast path's whole effect is that re-render, so recording the change as applied would leave the rig on a cadence the operator never chose, with nothing to detect it. The recordedreasonnames the watchdog rather than the hashrate, which in that case never dropped. GET :8082/statusreturns the last change's outcome (applied/rejected/rolled_back/failed, withsource: "control", the changed keys, the backup path, and awarnings[]for any change that touched thermal protection). Every response also carries a derivedage_secondsnext to its ownapplied_at/accepted_atstamp, computed fresh on each request (never stored), so a record read long after the fact can't pass for current — the origin case: a rig's firstGET :8082/statusafter enabling control surfacing an 11-day-old record with no staleness cue (#344).GET :8082/status?change_id=<16hex>returns a specific change's outcome (or404) so a concurrent change can't steal your confirmation (#255) — while a change is still in flight (steps 2/3 above) it readspendinginstead (#344); a change superseded by a newer one before the oneshot ever reaches it is leftpendingforever rather than guessed into a fake outcome, its growingage_secondsthe signal something didn't finish. A claimed run that dies mid-apply —error()'s bareexit 1reachable throughoutapply(), or aTimeoutStartSeckill — instead records a terminalfailednaming the loss: an EXIT floor arms the moment the change is claimed, since the spool entry is already consumed and nothing else will re-drive it (#509). The new effective config shows up on the read API asrigforge.config, with arigforge.config_meta.revisionthat bumps whenever it changes (#253/#254), on/1/summary(=/2/summary) once apply completes.
Recovery. Every applied change leaves a timestamped snapshot in config-backups/ (owner-readable,
the newest KEEP_CONFIG_BACKUPS, default 20, are kept). The retention sweep runs on every outcome
that got as far as snapshotting, not on the applied ones alone (#438) — a rig stuck on a failing
disk keeps a capped backup directory rather than an unbounded one. The snapshots are handed to the
operator; on a root-owned tree the directory itself stays root-owned (see the root guard above). To
inspect or roll back by hand:
ls -t config-backups/ # newest first
cp config-backups/config-20260711-120000.json config.json
sudo ./rigforge.sh applyRemote upgrade (second opt-in). With "control_upgrade": "enabled" (only valid when control
is already enabled), the stack can also trigger this rig to upgrade its own RigForge to a newer
release: the control server stages the request and the internal control-upgrade verb (run by the
rigforge-control-upgrade.path unit, like control-apply for config changes) fetches, verifies,
and health-gates the swap with rollback. It refuses anything that isn't a real release newer than
the running one. Default off, and never on just because control is. The threat model and
decisions are in ADR 0002.
Polling an upgrade works like polling a config change, with a slightly richer vocabulary (#320):
GET :8082/status?change_id=<id> serves a non-terminal started once the root oneshot has claimed
the intent (so a poller can tell "mid-build" from "queued"), then one terminal outcome: applied
(the reason names the landed version), rolled_back, noop (already on the requested version
with no unfinished install — idempotent, not an error), throttled (inside the anti-beacon window —
retry later), or failed (with reason). A run that dies after claiming the intent (an abort, or
systemd stopping the unit) still records failed, with a reason saying the run was lost, the
checkout may be half-updated and the upgrade will not be retried: check the installed version and
request it again (#535). After such a run, a request for the same version is carried out again and
is not answered noop; it is still subject to the throttle window. When the fetch fails, the root
guard refuses the tree or the upgrade state cannot be used, the outcome is failed, with a reason
that says nothing was changed. Only a SIGKILL or a power loss can leave started as the last
record. The oneshot gets TimeoutStartSec=infinity (#510): a rebuild is hardware-dependent and can run well past
ADR 0002's ~10-minute estimate — twice over, since a failed forward attempt rebuilds the rollback ref
in the same run — so systemd's implicit 90s default would kill it mid-build. Nothing is left
unbounded by it: the D6 throttle is what bounds how often this path fetches and builds at all.
The unit runs as root, so when a fetch, checkout and rebuild (or the rollback) returns, it reowns everything
outside data/ (and .git) that differs from the checkout root's owner and group, leaving an operator-owned
clone operator-owned. A root-owned checkout is left alone (#798).
The root upgrade unit keeps its throttle lock and timestamp in
/var/lib/rigforge-control-upgrade, owned by root with mode 0700, separate from the
receiver's writable state. Unsafe ownership, permissions, links, file types, or timestamp contents
fail the upgrade before any fetch or build. Existing throttle files in the receiver's state are
left untouched and never migrated, so the first upgrade after this change starts a fresh cooldown.
"control": "disabled" + apply removes the units cleanly; uninstall removes them too, with both state directories under /var/lib. Linux-only.
The design and the decisions behind it are recorded in
ADR 0001.