Guide › Machines

Machines

Other computers to run tournaments on: a test box, a server, a second PC. Settings > Machines lists them. A machine is reached with SSH: nothing has to be opened on it but its SSH server, and the program keeps nothing secret.

Adding a machine

Add a machine, then on its card:

  • Name, Host (its name on the network, or its address), Port (22) and User, the account its tournaments run as;
  • Log in with: the SSH agent (ssh-agent on Linux and macOS, Pageant or the OpenSSH Authentication Agent service on Windows; add your key to it with ssh-add), or a Key file, RSA or Ed25519 (~/.ssh/id_ed25519). The passphrase of a key file is asked once a session: it stays in memory and is never written anywhere. The machine must know the key: its public half (id_ed25519.pub) goes in ~/.ssh/authorized_keys on the machine (ssh-copy-id user@host puts it there), or, for an administrator of a Windows machine, in C:\ProgramData\ssh\administrators_authorized_keys;
  • Folder there: RookStudio’s folder on the machine, for the program, its tournaments, books and tablebases, relative to the user’s home folder (rookstudio by default) or absolute (/srv/fcg, D:\fcg);
  • Budget: the cores and the memory the tournaments on the machine, and the engines of this computer’s tournaments that run there, may use at once; 0 takes what the test found, every thread but one and 80 % of the memory.

Test the connection logs in, then tells the machine’s system, threads, memory, the free space where its folder is, and whether RookStudio is installed there, in which version. The first connection shows the machine’s host key (its SHA256 fingerprint) and trusts it from then on (known_hosts.json in the profile, the broadcast tunnel’s too). When the key changes later, nothing is sent and the card says so, with Trust the new key for a machine that was reinstalled. Every failure names the machine and what to do: the host that cannot be reached, a key the machine refuses (and where its public half goes), a passphrase that is not the right one, no agent running.

Install RookStudio (Update RookStudio once it is there) copies the program to the machine’s folder over SFTP, then checks it starts there (rookstudio --version). It copies this program when the machine runs the same system (Linux x86-64 to Linux x86-64); for another one, a Windows machine from Linux say, download the release for that system and choose its program on the card (RookStudio for Windows x86_64). A copy cut by the network resumes where it stopped.

Engines on a machine

Engines on this machine: the library’s engines the machine has, each with its path there (/opt/engines/stockfish, C:\Engines\sf.exe). Check the engines checks each path: the program is there, can be run, and answers uci (xboard for a WinBoard engine) within 10 seconds. The mark beside it, and its tooltip, say what was found: the engine’s name, or why it does not run (missing, not executable, made for another system, silent).

An engine missing on the machine is copied there with Copy… on its row (or Copy <engine> to <machine> in the command palette, or the button of a start refused because an engine has no path there). The panel that opens says first what goes: the program, its size and the system it is built for, read from its first bytes (a Windows program, a Linux or macOS one, universal or not, or a script). A program the machine cannot run is refused before anything is sent, saying which build to choose: “Alpha is a Windows program; tc-box runs Linux: choose the Linux build of Alpha”. The architecture counts as well (x86-64 or arm64); an x86-64 build on an arm64 Mac runs only under Rosetta, and a format the program does not know is copied all the same: both are said, not refused. A script goes only to a Linux or macOS machine, and only when the interpreter of its first line (python3, /bin/sh) is there. Choose the <system> build of <engine>… takes another file of this computer, the Windows build of the engine say, checks it the same way, and keeps it for that machine: later comparisons and replacements use it, not the library’s program.

With its folder copies the engine’s whole folder beside the program (its working directory, or the program’s folder), for an engine that needs files beside it: its networks, a book. The panel counts its files and their size first, and names the engine’s options that point inside it (EvalFile of a network): in a tournament on the machine they point to the copy there, and the folder is the engine’s working directory. A folder of more than 2000 files is not offered (a program in /usr/bin is not to be copied with its folder), a .git folder is left out, and for a Windows machine a file name Windows cannot hold (:, *, ?, a trailing dot, CON, NUL…) is named and stops the copy before it starts. Files are copied as they are, line ends included.

Copy sends the files over SFTP to engines/<engine>/ in the machine’s folder, in the background with the time left and Cancel, resumed where it stopped after a cut; each file’s SHA-256 is compared with this computer’s after the copy, and files already there and the same are not sent again. On Windows the program keeps or gets its .exe; elsewhere it is made executable (chmod 755). Then the engine’s path on the machine is set to the copy and checked as Check the engines does. On a Mac, a program copied from another computer that does not start may need a signature or to leave the quarantine: the message gives the two commands to run there (codesign -s - and xattr -d com.apple.quarantine); the program does not run them itself.

The Build column compares the engine there with this computer’s, by their SHA-256 (Check the engines and Compare do it, this computer’s program hashed once until it changes): same build as this computer, or a different build there, with Replace with this computer’s. Replacing copies this computer’s program to the engine’s folder in the machine’s folder and points the engine there: a program elsewhere on the machine (/opt/engines/stockfish) is never overwritten, it stays as it was.

Books and tablebases on a machine

Check what the setup uses compares the opening book and the participants’ own books of the setup with the machine’s books folder, by size and SHA-256 (a book of the same name but another content is not the same book), and the setup’s Syzygy files of 6 pieces at most with the machine’s tablebases folder, by name and size. Push the missing files copies what is missing or different, in the background, with the time left; each book is checked by its hash once copied, each table by its size, and a copy cut short resumes. Tables of 7 pieces are not offered: they take terabytes. A tournament does not start on a machine without its book; tablebases missing are a warning (the adjudication and the engines do without them).

A tournament on a machine

In the setup, Run on (in Concurrency) chooses where the tournament plays: This computer, or a machine. Start then prepares it there: RookStudio must be installed there in this version (else Update RookStudio), every engine must have its path on the machine (else the start offers Copy <engine> to <machine>…), and the setup’s books must be in its books folder (else the start says which is missing, and Push the missing files puts it there); tablebases missing are only a warning. The tournament gets its folder in tournaments/ of the machine’s folder, with the engines, books and tablebases at their paths there, and its process starts there out of the SSH session (rookstudio --run <folder> --detach): it plays on whatever happens to the window or the network. The window follows it as a tournament of this computer: Live, Games, the standings, pause, stop and the changes, through the control channel of its process (rookstudio --attach <folder> over SSH).

Its card on the Tournaments page says On <machine>, and Reaching <machine>… while the connection is cut: the window connects again on its own, a little longer after each failure, and takes up the events where its copy stopped. The journal and the PGN files are copied back to the tournament’s folder here as they grow, every few seconds, so that Ratings, exports and the submission checklist read them; the machine’s folder stays the reference (machine.json here says which machine and folder). Closing the window leaves it playing there; the next launch shows it again. Resume of an interrupted tournament of a machine resumes it there. The machine’s budget (its cores and memory) is shared by its own tournaments, apart from this computer’s. One tournament plays on one machine: its games are not spread over several.

A machine needs an OpenSSH server (Linux, macOS, BSD; Windows 10 1809 and later), with an RSA or Ed25519 host key and SFTP, both there by default. Commands go through sh whatever the user’s shell is (fish or csh are fine), and through cmd on Windows, the default shell of its OpenSSH server.

Engines played from this computer

An engine of the library can run on a machine while the tournament plays here: a GPU engine on the GPU box, an engine built for another system, a machine kept for one engine. On its card, Runs on chooses This computer or a machine; Program there and Working directory there are then paths on the machine (empty: the program’s folder there), and the … buttons, those of the options that name a file included, look through the machine’s files. Once there are machines, Add… offers A program on <machine>…, Import… offers Every engine of a folder on <machine>…, and the machine’s Add an engine… offers A program there…. The engine is read, checked, and played in the console, the quick test and tournaments as an engine of this computer is. Its path is also the one of the machine’s list of engines, and its program’s SHA-256 there tells when it was rebuilt (Δ, read again).

The machine must have been tested once (Test the connection), so that its host key is known: an engine never connects to a machine whose key was not shown and trusted. The key’s passphrase, if it has one, is asked once a session, before the first read or the start, and kept in memory: the tournament’s process gets it from the window and keeps it, so that the tournament plays on after the window closes. --run in a terminal does not ask for it: use the SSH agent there.

Each engine is started through a relay, rookstudio --remote-engine <key>, which the process that plays it serves: one SSH connection to the machine for ten engines at most (the MaxSessions of an OpenSSH server), each engine started from its folder there. An engine whose relay goes is ended there too, by its process id, when it does not end by itself (on Windows, with the cmd that started it, whose id PowerShell tells).

Check measures the round trip to the machine, the median of a few isready. The clock counts it: the setup’s summary warns when it takes more than 5 % of the increment, or of the time a move has without one, with Set a margin of … ms (twice the round trip). A machine never tested stops the start, and so does a tournament that runs on another machine than the engine’s (one that runs on the engine’s machine plays it there as its own engine).

While the tournament plays, the Tournaments page has a Machines line under the cores: each machine, connected and what plays there, or since when it does not answer. A machine that does not answer is one entry under Needs action: its engines’ games are set aside and tried again, the others go on, with Try again and Test <machine>. A game that an engine lost because its connection broke (its end as a disconnection) is voided and played again, written in the journal with its reason (connection to its machine lost: <machine>); Health counts it apart, not as the engine’s crash. A machine cut off more than three times in an hour has its engines set aside. This computer’s cores, memory and GPUs do not count the engines on machines, only their relays: each engine counts in its machine’s budget, shared with the tournaments that play there, and a game waits while its engine’s machine is full. The Machines line shows the cores in use of each machine’s budget.

A Windows machine

Windows 10 (1809 and later) and Windows 11 include an OpenSSH server, not installed by default. In PowerShell, as administrator:

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service sshd -StartupType Automatic

The installation opens port 22 in the firewall. Then put your public key in C:\Users\<user>\.ssh\authorized_keys, or, for an account of the Administrators group, in C:\ProgramData\ssh\administrators_authorized_keys, which only Administrators and SYSTEM may read (the groups are given by their SIDs, the same in every language of Windows):

icacls C:\ProgramData\ssh\administrators_authorized_keys /inheritance:r /grant "*S-1-5-32-544:F" /grant "*S-1-5-18:F"

Keep cmd as the server’s shell: RookStudio speaks cmd, not PowerShell (if a DefaultShell value was set under HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH, remove it). On the machine’s card, choose the Windows release’s rookstudio.exe, then Install RookStudio.

In RookStudio, F1 opens this guide beside the page, at the section of what is under the mouse.