GitHub 0

Run a command on every machine you reach

Name hosts and Tailscale tags. fleethosts turns them into ssh targets, runs one command on all of them at once, and tells you what each machine gave back.

Install fleethosts as a dependency.
Read https://fleethosts.loadsheet.dev/guide/hosts, then run commands on our machines with resolveHosts and runOnHosts, passing standardPlaces("<our program>").
text
uptime.ts
import { resolveHosts, runOnHosts, standardPlaces } from "fleethosts";

const places = standardPlaces("mytool");
const runs = await runOnHosts(
  places,
  async (remoteCommand) =>
    (await resolveHosts(places, ["vps", "tag:servers"], { remoteCommand })).targets,
  ["uptime", "-p"],
  30_000,
  { here: false },
);
for (const run of runs) console.log(run.host, run.exitCode ?? run.error);
ts
node uptime.ts
vps 0
web-1.tail4f2a.ts.net 0
web-2.tail4f2a.ts.net offline in Tailscale
text

No runtime dependencies: fleethosts runs ssh and tailscale from the machine.

Hosts

Check entries, expand tags, run on each machine, record the fleet

Exec

Run a command to the end, with a timeout and a cancel that stop what it started

Places

Your program's folders and the names it writes under

An unreachable machine gets an error and no exit code, so it never reads as a failed command.

Built with ViteHub Docs