Agent CLI Arguments¶
This page documents the current Swarm Hosts swarm host agent CLI.
For the installed Linux system service, registration behavior, and bounded diagnostics, see Linux Agent Recovery.
Basic Usage¶
./swarm-agent --name <HOST_NAME> --user-token <ENROLLMENT_CODE> [options]
Primary Arguments¶
| Argument | Default | Purpose |
|---|---|---|
--server |
SWARM_SERVER_URL, otherwise https://swarmhosts.com |
Control plane base URL; omit for the public Swarm Hosts service |
--name |
current hostname | Friendly swarm host name shown in the UI |
--user-token |
SWARM_USER_TOKEN |
One-use code from Profile → Connect a host; expires after 15 minutes |
--identity-file |
~/.swarm_agent/identity.json on Linux; C:\ProgramData\SwarmHosts\agent\identity.json on Windows |
Cached host identity; the Linux installer sets /var/lib/swarm-agent/identity.json explicitly |
--force-register |
false |
Explicitly remove the cached and pending identity, then enroll a new host; does not erase saved operation-recovery state or protections against duplicate servers |
Commands¶
| Command | Purpose |
|---|---|
run |
Start the normal agent loop; this is the default when no command is given |
diagnostics monitoring |
Print local monitoring diagnostics; use the installed service's identity and data paths |
configure-ports |
Save a port-range proposal for an already enrolled host; restart the agent to submit it |
--enrollment-protocol |
Report enrollment compatibility without starting the agent |
--help |
Show the arguments accepted by the installed binary |
Default agent behavior¶
These behaviors are built into the swarm host agent and are not CLI options.
| Behavior | Default | Purpose |
|---|---|---|
| Heartbeat interval | 15 seconds |
Reports host health and capacity to Swarm Hosts |
| Task polling interval | 5-second base, longer when idle |
Checks for Swarm Server and host actions; idle polling slows automatically |
| Auto-update checks | enabled every 600 seconds |
Binary builds check for newer agent releases |
| Image pull behavior | pull when missing locally | Swarm Server images are fetched when the host does not already have them |
| Unused image pruning | enabled at 80% selected runtime storage usage |
When Docker or Podman storage crosses the threshold, the agent runs the matching image prune -a --force command with a cooldown |
| Runtime command debug logging | disabled | Container runtime commands are not logged individually |
Owners and swarm host admins can also open a swarm host's Operations tab and queue Prune unused images. Manual prune requests run immediately instead of waiting for the automatic threshold check.
Swarm Server Runtime¶
| Argument | Default | Purpose |
|---|---|---|
--data-root |
SWARM_DATA_DIR, /var/swarm/deployments on Linux, or C:\ProgramData\SwarmHosts\deployments on Windows |
Host directory used for each Swarm Server's persistent data |
--storage-config |
SWARMHOST_STORAGE_CONFIG_FILE, otherwise storage-locations.json beside the agent identity |
Managed storage selection loaded and validated at boot; Linux requires 0600, while Windows requires a verified service-owner/admin-only ACL |
SWARM_CONTAINER_RUNTIME |
auto |
Selects docker, podman, or auto; auto prefers Docker when ready and falls back to Podman on Linux |
SWARM_PRIMARY_BACKUP_DIR |
<data-root>/.backups |
Legacy primary-backup directory when no managed storage selection is valid |
SWARM_REPLICA_DIR |
<data-root>/.backup_replicas |
Host directory used for assigned replicated backup archives |
SWARM_REPLICA_REHYDRATE_TIMEOUT_SECONDS |
120 |
Max time a restore waits for a remote verified replica to rehydrate through the control plane |
SWARM_REPLICA_REHYDRATE_POLL_SECONDS |
2 |
Poll interval while waiting for remote replica rehydration |
SWARMHOST_IMAGE_PRUNE_ENABLED |
1 |
Set to 0 to disable automatic unused container image pruning |
SWARMHOST_IMAGE_PRUNE_THRESHOLD_PERCENT |
80 |
Selected runtime storage usage percent that triggers unused image pruning |
SWARMHOST_IMAGE_PRUNE_CHECK_INTERVAL_SECONDS |
60 |
Minimum interval between storage-pressure checks |
SWARMHOST_IMAGE_PRUNE_COOLDOWN_SECONDS |
3600 |
Minimum interval between prune attempts while storage remains above threshold |
Swarm host Port Range¶
| Argument | Default | Purpose |
|---|---|---|
--port-range-start |
SWARM_HOST_PORT_RANGE_START |
First host port the swarm host may use for Swarm Server mappings |
--port-range-end |
SWARM_HOST_PORT_RANGE_END |
Last host port the swarm host may use for Swarm Server mappings |
Both range arguments must be supplied together. They set the first enrollment proposal. An enrolled host loads its accepted range from the saved identity; changing startup arguments alone does not replace it.
To propose a correction, first review active operations, stop only the agent
service, and run configure-ports using the same server, identity, and data
paths as the service. For the default Linux installation:
sudo systemctl stop swarm-agent
sudo /opt/swarm-agent/swarm-agent configure-ports \
--identity-file /var/lib/swarm-agent/identity.json \
--data-root /var/swarm/deployments \
--port-range-start 40000 --port-range-end 40100
sudo systemctl start swarm-agent
The command saves a proposal; the next agent start submits it. Check the host
page for acceptance or rejection. An accepted range change can redeploy game
servers. Use configure-ports --use-accepted with the same identity and data
paths to propose using the current accepted range again. Neither form accepts
an enrollment code or --force-register.
Relay Access¶
Relays are platform-operated infrastructure. A host enrollment code cannot enroll a relay.
When relay-backed access is available for your account, it is selected from the Swarm Server workflow.
Logging¶
| Argument | Default | Purpose |
|---|---|---|
--log-level |
INFO |
Python logging level |
Important Environment Variables¶
SWARM_USER_TOKENSWARM_CONTAINER_RUNTIMESWARM_DATA_DIRSWARMHOST_STORAGE_CONFIG_FILESWARM_PRIMARY_BACKUP_DIRSWARM_REPLICA_DIRSWARM_REPLICA_REHYDRATE_TIMEOUT_SECONDSSWARM_REPLICA_REHYDRATE_POLL_SECONDSSWARMHOST_IMAGE_PRUNE_ENABLEDSWARMHOST_IMAGE_PRUNE_THRESHOLD_PERCENTSWARMHOST_IMAGE_PRUNE_CHECK_INTERVAL_SECONDSSWARMHOST_IMAGE_PRUNE_COOLDOWN_SECONDSSWARM_HOST_PORT_RANGE_STARTSWARM_HOST_PORT_RANGE_END
Examples¶
The swarm host owner can open Swarm Host → Operations → Game and backup drives to discover local drives or mounts and browse safe directories. The control plane stores the desired selection and the agent writes its versioned managed configuration. After the agent saves a new selection, restart it so every runtime subsystem uses the boot-validated paths. The host page reports whether the selection is pending, active, using a prior-known-good setting, or blocked by validation.
The host page shows capacity for the selected local filesystems. Game and backup locations on the same filesystem share its available space.
Choose locations from the host's discovered local drives. Network shares, UNC paths, symlinks, and Windows junctions are not accepted. The agent refuses to change roots while the current or selected locations contain data; no automatic migration or adoption occurs.
Storage selection is an empty-host onboarding workflow. Finish the selection before creating the first Swarm Server or backup. Once either exists, the host page locks location changes instead of offering to move data.
For a managed backup selection, the chosen root is partitioned as
primary/ for locally created backups and replicas/ for zone replicas.
Basic swarm host registration:
./swarm-agent --name lab-host --user-token <ENROLLMENT_CODE>
Increase log verbosity:
./swarm-agent --name lab-host --user-token <ENROLLMENT_CODE> --log-level DEBUG
Use a custom data directory:
./swarm-agent --name lab-host --user-token <ENROLLMENT_CODE> --data-root /srv/swarm/deployments
Windows PowerShell example:
.\swarm-agent.exe --name lab-host --user-token <ENROLLMENT_CODE> --data-root 'C:\ProgramData\SwarmHosts\deployments'
Configure a swarm host-specific port range:
./swarm-agent --name host-a --user-token <ENROLLMENT_CODE> --port-range-start 40000 --port-range-end 40100
Notes¶
--user-tokenis required to begin first registration. Use the installer’s hidden prompt when possible to keep the code out of shell history.- An interrupted registration uses the private
pending-enrollment.jsonbeside the identity file. Restart with that file intact to resume the same host. If an unused code expires, supply a fresh one; the host identity is preserved. Never print either identity file. - Account tokens and personal API tokens cannot enroll hosts. Existing enrolled hosts do not need new codes.
- A rejected stored host identity is preserved for recovery; the agent never silently creates a replacement host.
- Check Profile → Agent download for current binary support. A first install requires one-use enrollment support; older source builds and unsupported Windows binaries receive an update-required error.
- Use
--serveronly when your account belongs to a separately managed private control plane. Bare hostnames are treated as HTTPS. - Linux and Windows expose the same user-facing feature set. Current availability still depends on the host runtime and operating-system prerequisites. See Windows Swarm Host Agent and Swarm Host Compatibility.
Swarm Zone replica networking¶
For replication, both peers must report LAN backup replication → Ready with fresh private LAN addresses. Read the source host's LAN backup gateway port from its Overview page; the end of its game-port range is not a substitute.
Allow inbound TCP to that port only from the other private addresses in the
same zone. Do not expose the LAN backup endpoint publicly. The default
per-archive limit is 64 GiB (SWARM_LAN_REPLICA_MAX_BYTES), and each network
connect/read operation has a 120-second timeout.
When both peers support incremental transfer, they exchange an encrypted manifest and only the backup chunks missing from the target. Older peers or a failed negotiation use the encrypted full-archive LAN transfer. Zone backup data does not use the public game relay.
Backup files share local storage where hard links are available. A filesystem that cannot create hard links uses full local copies, which require additional disk space and write activity. Incremental transfer also retains compressed chunks referenced by backup manifests; leave room for both the restore archives and that chunk storage.