Skip to content

Install the runner

The install script creates a dedicated user, writes the configuration, installs the runner as a systemd service, enrols it with the platform, and installs the command yousleep-runner for operating it. Run it as root. You can run it again safely.

Before you start

An owner or admin of your organisation opens Add a runner on the platform, with you. The page creates the enrolment token, which enrols one runner, once, and builds every command below from the settings chosen there: the storage addresses the runner may reach, its name, the cores and memory it offers, its home, and a registry login if you need one. Set up a site says who does what before and after.

The runner talks to https://api.yousleep.ai. Each release carries that platform's root key, which the runner checks every answer against, and the install pins it. For another platform, give --api-url and that platform's root key, --root-key.

If the analyses' images are in a registry your site operates, name it on the page: the page then shows the podman login command that saves the login, and the install command hands it to the runner (--registry-login).

Install

Run the commands Add a runner shows, on the computer, in order:

  1. Write the install files. The first command makes a directory and writes into it, from the runner's image named by its digest: install.sh, the command yousleep-runner, the service definition yousleep-runner.container and config.example.toml.
  2. Save the token in token.txt, a file only you can read, once the page shows the token.
  3. Run the install script as root. It reads the token from token.txt on standard input, so no command line or shell history holds it, and does not store it. Delete token.txt once the runner has enrolled.

The script checks the host, enrols the runner, pulls the images of the analyses it may be asked to run, and starts it. It ends by printing the runner's key fingerprint and its limits. If an image fails to pull, the script names it and the reason, and carries on.

Options

Option Effect
--root-key The platform's root key. The release carries the root key of https://api.yousleep.ai; give it only for another platform
--storage-origin The storage address. Repeat it for more than one. A link-local or unspecified address, such as a cloud host's metadata address, is refused
--home The directory where the runner keeps its key, its state and its jobs' files; by default /var/lib/yousleep-runner, or /var/lib/ and the name given to --user. Use an encrypted volume. A directory that exists must already belong to the runner's user
--registry-login The login file podman login --authfile saved, for a registry your site operates
--cores, --memory-mib The cores and memory the runner offers; by default the host's, less one core and a quarter of the memory
--max-job-cores, --max-job-memory-mib The largest single job; by default everything the runner offers
--image-cache-gib The disk the analysis images the runner pulls may take, in GiB; past it, the least recently used are removed. By default 50
--disk-reserve-gib The disk the runner keeps free for the host, in GiB. It offers the rest of its home's free disk to jobs, and the platform leases it only jobs whose files fit. By default 10
--job-kind A kind of job the runner takes: analysis; ingest, which reads a new recording once; or delete, which removes an upload from your organisation's bucket. By default all three. Repeat it for more than one
--share-log-tails Send a job's last log lines with its result, so the platform can say why a run failed. Leave it off at a site: the logs can contain what the recording contains. --no-share-log-tails turns it off
--name The name administrators see; by default the host's name
--api-url A platform other than https://api.yousleep.ai
--user The runner's user; by default yousleep-runner. Each user has its own configuration, in /etc/ under the user's name, so a second runner on the same host takes another user. Name it to the command too: sudo yousleep-runner --user and the name, then the command
--image The runner's image; by default the release the install files came from. An image named by its digest runs as named; one named by a tag runs by the digest the tag names when the script pulls it
--https-proxy A proxy every connection out goes through, such as http://proxy.example.com:3128, with a user and password in it if the proxy needs them. The runner, its pulls of the analyses' images, doctor and the install itself use it. --no-https-proxy removes it
--proxy-bypass Hosts reached directly rather than through the proxy, separated by commas, such as your bucket on the site's network: storage.lab.example.com,.lab.example.com
--ca-bundle A PEM file of certificates trusted beside the public ones: your own certificate authority, when it signed your bucket's certificate, or your proxy's, when it inspects TLS. --no-ca-bundle removes it

To change settings later, run the script again with only the options you change. It keeps the other settings and shows what changed. A repeated option, such as --job-kind, replaces the whole list. The file is rewritten, so comments in it are not kept. The script checks the new settings before it writes them, so a mistake leaves the runner as it was.

Approval

After enrolling, the runner waits for approval. Read the fingerprint the script printed on the host itself. An owner or admin of your organisation approves the runner on the platform with it, on Add a runner or the Compute page; the platform compares it with the runner's key and refuses an approval that differs. The runner then starts taking work.

To print the fingerprint again, see Check the runner.

What the install script does

  1. Checks the host: Linux, cgroup v2, Podman 5.7 or later.
  2. Creates the user yousleep-runner, with subordinate user and group ids for rootless Podman.
  3. Enables lingering (loginctl enable-linger), so the user's services start at boot.
  4. Delegates the cpu, memory and pids controllers to user services, if they are not delegated already.
  5. Enables the user's Podman socket.
  6. Writes /etc/yousleep-runner/config.toml (for another --user, the same file under /etc/ and that user's name), owned by root. The runner reads every limit from it alone and never writes it. A registry login goes beside it as registry-auth.json, and the proxy as proxy.env, both readable only by root and the runner's group. A certificate bundle goes beside it as ca-bundle-*.pem, named by its content, so the runner keeps the one it has until the new settings have checked the host.
  7. Creates the runner's home and checks that the user can reach it.
  8. Pulls the runner's image, and from then on runs it by its digest.
  9. Checks the host with the new configuration, and enrols the runner if it is not enrolled yet. If either fails, the script stops and the runner stays as it was.
  10. Pulls the images of the analyses the runner may be asked to run. A failed pull is reported and does not stop the script.
  11. Writes the configuration and the proxy, points the user's Podman at the proxy, installs the service and the command yousleep-runner (in /usr/local/bin), and restarts the runner.