We follow our own README on a brand-new Ubuntu machine, from git clone to a laptop playing on it across the network, and fix each thing that gets in the way. A doctor script checks the tools, libraries, Docker, ports and certificates, and prints one command that installs what's missing. The build loses its six hundred warnings, and Docker Compose stops publishing Redis and MySQL to the network. The servers find their files from any folder, a refused TLS handshake says what's wrong with the certificate and what to do, the certificates script adds the server's address, and a second world on one machine says its metrics port is taken. The steps end up on a getting started page, in the docs and on the website. This is episode 65 of a series about building an MMORPG from scratch in C++, with the focus on the engineering around the game.
The code
Each step on screen is a tag in the game's repository. The code at the end of the episode is ep065/end.
Transcript
Intro
0:00 Welcome back to episode sixty-five, where we're going to take a brand-new machine and follow our own README on it, from the first git clone. We fix each thing that gets in the way, until a laptop plays on it across the network. I think this matters more than it sounds, as the first half hour with a project decides whether someone carries on with it, and ours had rough edges I'd stopped seeing. First, a quick look at where we'll be by the end.
0:28 A laptop logs in to a server across the network, an Ubuntu machine that had nothing on it an hour earlier. It enters the world there, as the server's certificate names its address, and the world tells players where to find it.
0:45 The series has a website, where the code is linked on GitHub, and each episode gets a page, with the code at each of its steps.
Last time
0:53 Last time, the hotbar got slots of brass, and a skill dragged onto another swaps with it, in an order the settings keep. Items drag with their pictures, lit green or red by the server's own rules, which the client links as a library. A move shows straight away, before the server answers, and goes back if it says no. And the login, the worlds and the characters got the game's look.
A new machine
1:16 This is a brand-new Ubuntu twenty-four point oh four, which stands in for a server we've just rented, or a new developer's laptop. It's a virtual machine I made on my Mac a few minutes ago, so nothing of ours is on it. First, we clone the game from GitHub, which the README takes as done, without saying how.
1:36 Then we do what the README says, in its order. Its first command installs the libraries the game builds against, with apt. On a machine this new, apt's list of packages is older than what's on Ubuntu's mirrors, so nine of them aren't there any more, and apt suggests apt get update, which isn't in the README. Its next command runs CMake, which isn't installed. The README says we need CMake, Ninja and a C++20 compiler, but its apt line installs none of them. My own machine has all of these, so I'd stopped noticing, which is the trouble with checking a README on the machine it was written on.
2:11 So, today we follow the README until a laptop plays on this machine, and fix what gets in the way, in the game where we can, so the next person doesn't meet it. There's a doctor script that says what a machine is missing, and how to get it, and a build without six hundred warnings. The programs run from any folder, and TLS errors say what's wrong with the certificate. The certificates script adds the names you ask for, and there's a getting started page, of steps and tables. All right, let's get started, with the doctor first.
A doctor
2:45 What I'd like is a script that looks at the machine and says what's missing, as a list in a README is something you compare by eye, and it goes out of date without anyone noticing. So we write a doctor, next to deploy and release, in plain sh, which behaves alike on macOS and on Ubuntu. Set dash u stops the script on a variable we forgot to set. Above it, we write what the doctor checks: the tools, the libraries, Docker, the ports and the certificates. It says what to do about each thing that's missing, and ends with one command that installs all of it, with Homebrew or apt. It exits with one when the game can't do without something. We move into the script's folder, so it can be run from anywhere, and mac picks between Homebrew and apt further down. Missing is that exit code, and packages collects what to install. Then three ways to print a line: a green tick, a yellow exclamation mark for something worth knowing, and a red cross, for something the game needs and this machine hasn't got, with what to do about it. Want is what most of the checks call. It takes the package's name for each package manager, as they often differ. It prints the install command for this machine, and adds the package to the list, for the last line to install in one go. Has asks command dash v whether a program is on the path, and at least compares versions with sort dash V, which knows that three point twenty-eight comes after three point nine, where a plain sort gets it wrong. On a Mac, Homebrew keeps two of our libraries where pkg-config doesn't look, so we ask brew where each one is, add it to pkg-config's path, and export that, as the CMake file does for CMake. Then the checks, in the order you'd need things, with git first, and its version when it's there. A missing CMake goes on the list, and otherwise we read its version and check it with at least, as here the version matters. Our CMake file asks for three point twenty-eight, and Ubuntu twenty-two point oh four has three point twenty-two, so for that one, we say to get it from snap, which has the latest release. Then the build tool, Ninja, which CMake writes our build files for, and which Ubuntu calls ninja dash build. For C++, we print the first line of c++ dash dash version, which names the compiler we have. It comes from Xcode's command line tools on macOS, and on Ubuntu, from build essential, which brings GCC and make. The libraries go through pkg-config, which is how CMake finds the MySQL client library and libsodium too. Without pkg-config, there's no telling which of them are here, and on a new machine, the answer is none. So the install command gets the lot, as a package manager skips what it already has. The note lists them, for Homebrew on a Mac, and on Ubuntu for apt, along with X11's and OpenGL's headers. I prefer that to guessing from header files, which sit in different folders from one system to the next. With pkg-config, we ask for each library by name: the MySQL client library, which the servers reach the database with, then libsodium, which hashes the players' passwords with Argon2, and dash dash mod version prints its version. OpenSSL is for TLS between the clients and the servers, and dash dash at least version checks that it's three or newer. On Linux, raylib draws with OpenGL, in a window from X11, so we ask pkg-config for both, and when they're missing, their headers go on the list. Running the game needs Docker, for MySQL, Redis and Consul. On a Mac, that's Docker Desktop, so we link its page, and on Ubuntu, it's three packages from apt. Docker info tells us whether we may use it. This is the bit I like: its errors go where the output goes, which we capture, and then its output goes to dev null, so we keep the error alone. Permission denied means we're not in the docker group yet, which I think most people hit on Linux at some point. Anything else means Docker isn't running, so we say how to start it, from Docker Desktop or with systemctl. When it works, we print the server's version. Compose has to be two point twenty-four or later, as that's where override came in. The extra worlds use it to replace the ports they take from the first, instead of adding to them. When the plugin is missing, dash dash short prints nothing, and we say to install it. Otherwise, we strip a v from the front, if there is one, and compare them, so an old one gets a red cross too. Buildx gets a check too, as our Dockerfile mounts a cache for its compiles, which takes BuildKit, Docker's newer builder. Without a screen, as on a server, the client's tests can't open their windows. So when x v f b run isn't there either, we print a note with how to install it and run the tests on a virtual screen. It's a note and not a cross, as the build and the game work without it. Ports next, as a MySQL or a Redis of your own on these ports is a common way for Compose to fail. Listener finds what holds a port, if anything, and gives back a container's name, or a program's. When Docker is here, docker ps can say which container published the port, by its name, and that's our answer. On Linux, ss lists what listens on the port, and sed picks out the process's name. Without root, ss doesn't show another user's processes, so for those, we print that it's a program of another user. And on macOS, lsof does it, with awk taking the name from under its header. Then the services, each in one string with its number, as plain sh has no arrays. We cut each string in two at the colon, for the port and the name, and ask listener who holds that port. A free port gets a tick, and so does a holder whose name starts with nanommo, as that's one of our own containers or servers. Anything else gets a note to stop it, as that service can't start otherwise. Last come the certificates, and when the servers' one is there, OpenSSL prints it as text, and sed takes the names under Subject Alternative Name. The names matter as soon as a client connects from another machine. Without one, the note says the certificates script makes them, before the servers start. And when something was missing, the last line has one command that installs all of it, with apt update first, as a new machine's list of packages is out of date. The script exits with missing, so a script or CI can tell. In the CMake file, the version goes to zero point sixty-five.
9:16 On the server, with this step's code, we run the doctor. Git is there, as Ubuntu's cloud image comes with it, and everything else for building is a red cross: CMake, Ninja, a compiler and pkg-config. Without pkg-config, it can't tell which libraries are here, so they all go in. Docker isn't here either, there's a note about running the tests without a screen, the ports are free, and there are no certificates yet. The last line is one command that installs all of it.
9:46 So we run that line, and tell apt yes. It's about two hundred packages, which takes a minute and a half, and it's sped up here. Then we join the docker group, before the doctor gets the chance to tell us. A group takes effect at the next login, so on your own machine you'd log out and in again, while here each command logs in to the server afresh, over SSH. The doctor again, and each line for building and running is a tick, with a note about the screen, and no certificates, which come later.
Building and testing
10:16 With the tools in place, CMake configures the build for Ninja, and fetches the libraries the system doesn't have. Then the build, which compiles protobuf and the other libraries, then our code. It takes about four minutes on this machine's four cores, sped up here, and a lot of warnings scroll past on the way. Grep counts six hundred and six warnings, and five hundred and fifty-one of them are in our own code, which we'll come back to.
10:44 Then the tests, with ctest, which runs the two hundred and thirty-nine tests the build made, one after another, in about six seconds. Fourteen of the client's tests fail: the renderer, the sea, the characters, the rig, the effects and the figures, which open a window to draw in. A server has no screen to open one on. The doctor's note from earlier has the fix for it. X v f b is a display server that draws into memory, and x v f b run starts one around a command, so the tests that open a window get one. With it, the client's tests pass as well, and thirty-two are skipped, the ones that test against MySQL, Redis or Consul, as each waits for a variable that says where to find them.
The servers
11:27 Docker Compose starts MySQL, Redis and Consul, and the saver, which takes players from Redis into MySQL. The saver is our own code, so Compose builds its image first, which compiles the whole game again, in Docker. That took about eight minutes the first time, and it's sped up a lot here. The certificates script makes our own certificate authority, and a certificate for the servers. The login server starts on port seven seven seven eight, and the world, Ember, on seven seven seven seven, and registers with Consul. From here on, both run in the background. With the services up, we give the skipped tests their hosts in three variables, so they run too. The MySQL library takes localhost to mean a socket file, so the hosts are one twenty-seven dot zero dot zero dot one, and this time all two hundred and thirty-nine pass.
12:20 The game is up, and my laptop tries the server's Redis port from the network they share, and gets through. Redis answers its ping, without asking for a password. It holds the players' sessions and where each of them is, so on a rented server, anyone who finds the address could read and change them. Compose published it on each address the server has, like MySQL and Consul, and the file does that for the monitoring too.
Quiet, and closed
12:48 Six hundred warnings is a wall nobody reads, and a new one about a real bug would get lost in it. So, in the CMake file, after turning warnings on, we turn off missing field initializers, which five hundred and fifty of them were. The reason goes above it: designated initializers leave the fields they don't name at their defaults, which is how we use them, so a warning for each of them buries the ones that matter. To me, that beats spelling out each field we leave at its default, in about ninety places, which would make each of them longer and harder to read. The one warning left of ours is in content, where serialize to coded stream returns a bool for whether it worked. It's marked no discard, an attribute that makes the compiler warn when a result is dropped, and we dropped it. A cast to void says we've looked at it and chosen to drop it, and why that's fine goes above it. Writing into memory fails when a message lacks a required field, and that can't happen here, as the content was read whole. Then the compose file, which is why the laptop's ping got an answer. Over the services, we write which is which: players reach the login server, the worlds and the website from anywhere, and the rest listens on this machine alone. A database, Redis and Consul open to the network, with the passwords in this file or none at all, are anyone's to take. A port Docker publishes can start with the address it listens on, and without one, it listens on all of the server's addresses. So MySQL, Redis, ClickHouse and Consul get one twenty-seven dot zero dot zero dot one, and so do the game server's metrics, the storyteller and the monitoring. We could have left this to a firewall, but Docker writes its own rules for the ports it publishes, and they skip past the firewall Ubuntu comes with. So I'd say it here, next to each port, like the production file on the VPS already does.
14:39 Back on the server, at the new step, the build compiles our code again, as its flags changed, and leaves the libraries alone, so it's done in a little over a minute. This time grep finds no warnings at all, and the libraries' fifty-five didn't come back either, as they weren't built again. Then Compose starts the services again, with their ports on the server's loopback.
15:04 From the laptop, the connection is refused now, and so is the ping, while the programs on the server still reach Redis on one twenty-seven dot zero dot zero dot one.
From any folder
15:14 The next thing I tried was starting the server from the build folder, out of a habit from other projects. It can't read content slash figures, as it looks for the content folder in the folder it's started from. The login server's message is worse, as it sends you the wrong way. It says the certificates script makes them, and they're there already, one folder up.
15:37 The paths a program reads come from settings, which are environment variables with a default, and the default is relative to the folder we're in. I'd keep the settings, as Docker and a VPS want their own paths, and change where a default looks. In the settings' header file, next to Setting, File Setting takes the setting's name and a path in the repository. Over it goes what it gives back, which is the setting called name, when it's set. Or else, it's the path in the repository the program was built from, so it runs from any folder. A Docker image holds our programs without the repository, so where the repository hasn't got it, the path is from the folder it runs in, like before. And a path in neither comes back from the repository, as that's where an error should send you. In settings, we include our header, then unistd, which is the POSIX header for access, a call that asks the system whether a file is there. The standard file system header could do that too, but cpplint, which checks our style, rejects it. Then cstdlib for getenv, string, and Abseil's str cat, to join the paths. Exists wraps access, in an unnamed namespace, as no other file needs it, and F OK asks whether the file exists, whether or not we may read it. File Setting starts with the environment, like Setting, so a setting that's set wins over the rest. The repository's path comes from NANOMMO source dir, joined with the path we're given, and over it, we say that the build puts the repository's folder there. When the repository has the file, or the folder we run in hasn't got it either, the repository's path is the answer. Otherwise, it's the path as it was, from the folder we run in, which is what a Docker image needs. In the protocol's CMake file, settings joins the library's sources. Its source file alone gets NANOMMO source dir, as a compile definition, set to project source dir, which is the folder CMake found the repository in. Putting it on that one file keeps the repository's path out of everything else, which doesn't need it. We note over it that it's where the repository is, for the files the programs read from it. And the new test joins the protocol tests. Then the places that read files go through File Setting. In the server's main, that's the content, which is where it failed from the build folder, and then its certificate and its key. The login server reads a certificate and a key too, which were the ones its message sent us the wrong way about. The bot reads the authority, to check the servers' certificate, and the content, as it plays by the game's rules too. And the client reads the authority, while its content and assets were found next to its binary already.
18:16 Now, a quick test that File Setting finds things from another folder, which is the case that failed. We include our settings' header file, then sys stat, for making a folder, and unistd, for access and for moving between folders. Array holds the folder we start in, cstdlib sets and clears a variable, and then GoogleTest. The test has its own Exists, as the one in settings is in an unnamed namespace, out of reach. A fixture runs each test from GoogleTest's temporary folder, outside the repository, and goes back after, as we write above it. I'd sooner have the test change folders than give File Setting a folder to look from, which nothing but the test would use. Set up keeps where we were, with get c w d, and moves with ch dir. Tear down goes back, and clears the setting the tests use, so one test's setting doesn't leak into the next. From there, content comes back as the repository's folder, with our items file in it, which is the case from the build folder. Then a folder the repository hasn't got, which we make in the temporary folder, comes back as it is, from the folder we're in. That's what a Docker image needs, where the repository isn't there at all. The setting wins over both, so a VPS can still point a program anywhere, with an absolute path in an environment variable. And a file that's in neither place, say a missing key, comes back as a full path into the repository's tls folder, which is where the error should send you. Starts with and ends with, which strings got in C++20, check that it's a full path, ending in the tls folder.
19:52 At the new step, the four tests for File Setting pass, and the login server starts from the build folder, with the certificates from the repository.
Another computer
20:01 Now the laptop, which is my Mac, with the game as last episode left it, built in Docker. The client takes the server's address, and we log in as arthur. It couldn't reach the server, and certificate verify failed is all OpenSSL says about why.
What's wrong with the certificate
20:18 Certificate verify failed is all the client could tell us, and at least three different problems end in it, each with a fix of its own. The name check was asio's host name verification, a callback that fails the handshake without keeping why, while OpenSSL's own check of the name stores the reason. In the TLS header file, we bring in system error, the standard library's header for error codes, as asio hands us a failed handshake as one. Expect Name gives the host we're connecting to over to OpenSSL's check, before the handshake starts. So a client's handshake checks that the server's certificate names the host, which can be a domain name or an address, in a way Handshake Error can tell apart afterwards. Then Handshake Error takes the stream, the host, and the error code asio gave us. It returns why a client's handshake with that host failed, and what to do about it, as a string, since its callers put it straight into a message for a person. In TLS, we bring in OpenSSL's S S L header, for the connection's verify result, and its verify header, for the parameters of the check and the error codes. And asio's address header, to tell an address from a name. Expect Name starts from the verify parameters OpenSSL keeps on the stream's connection, which we reach through asio's native handle, the S S L pointer underneath. With these, OpenSSL checks the name on its own, and keeps why it failed, for us to read. To pick which check, we try to read the host as an address. asio's make address has a version that throws and one that fills in an error code, and we take the error code, as the style guide doesn't use exceptions. When the host isn't an address, set one host gives OpenSSL the domain name to look for. The one in set one means OpenSSL keeps a copy of the string, so our host can go away after the call. An address goes in with set one IP A S C, which takes it as ASCII text. A certificate lists addresses apart from names, and a name check wouldn't look at them. Handshake Error is for after a handshake has failed. S S L get verify result gives back the reason the certificate check stored, as a code, and we switch on the codes we know what to say about. A certificate that doesn't name the host, or doesn't list the address, gets the command that makes one that does. The command runs the certificates script on the server, with the TLS folder and the host, and then the servers start again to load it. A certificate from another authority comes in a few codes, and the signature failure is the one I didn't expect. All the authorities our certificates script makes are named nanoMMO authority, so OpenSSL finds ours by that name, and a certificate signed by another copy's authority fails on its signature. The others are an issuer we don't have at all, or a self-signed certificate, in the chain or on its own. They all get one fix: copy the server's authority certificate here, or set NANOMMO TLS CA to where it is. An expired certificate gets told to make new ones on the server, with the certificates script. Anything else keeps asio's message, OpenSSL's words, as before. I prefer those to a guess, as a wrong hint sends someone off to fix a problem they don't have. In the login client, asio's host name verification header goes, and Expect Name takes the place of the callback. A failed handshake now returns straight away, before we try to send the request, as unavailable. The message says it couldn't shake hands with the login server, followed by Handshake Error's reason. The client's connection to the world does likewise. Its include goes, and Expect Name checks the host of the world we're entering. A failed handshake says it couldn't shake hands with the world, where it used to say the server, and Handshake Error adds why. In the bot's header file, Greet takes the host as well, between the token and the error. In the bot, the verification header goes too. The resolver keeps the name we looked up, so we take the host from its first result, and hand it to Expect Name. The connect lambda captures the host along with this and the token, as a copy, since it runs after Start has returned and its locals are gone. The handshake's lambda passes the host on to Greet, whose definition takes it before the error code, like its declaration did. If the bot couldn't shake hands, Greet now prints why, from Handshake Error, in place of asio's message. So a bot run against another machine says why it can't get in, like the client. The client gets one more change, in its main. This Machine says whether a host is the machine it's said on, which is localhost, or the loopback address in IPv4 or IPv6. Enter goes into the world as the character the token's for, at the address the world gave Consul, and it now takes the host of the login server too. We delete the old error message, and keep the reason in why, so we can add to it. We add to it when the world says it's on this machine, and the login server we reached isn't. A world started without NANOMMO public host gives Consul localhost, which from another machine is that machine, not the world's. So the message gets the world's name, where it says it is, and to start its server with NANOMMO public host set to the login server's host. That address is a guess, as a world can run on another machine than the login server. I think it's a fair one, as on our server, the login server and the world run side by side. And main passes the host it logged in to. The host is the address we gave the client on its command line, or localhost without one, so the hint names an address the laptop has reached already.
26:01 Now, let's have the TLS test check the reasons the client gives. We bring in Abseil's match header, for Str Contains, and asio's verification header goes. The helper that said yes or no becomes Refusal, which takes the server's and the client's TLS contexts, and the host the client asks for. It returns why a client that checks the certificate for that host's name can't shake hands with the server, over this machine's loopback, and an empty string when it can. I like a reason better than a yes or no here, as a test that fails then prints what the client would have said. Inside, Expect Name takes the callback's place, like in the login client, and a failed handshake returns Handshake Error's reason. Our client connects with localhost, as before, and with one twenty-seven dot zero dot zero dot one, which goes through the address check. A client set up with their authority in place of ours is refused, and the refusal has to say the certificate isn't from the authority we trust. The arrows after the expectation print the whole refusal when it doesn't, so a failure shows the message we got. Then a new test, that the client says which name is missing. The test's certificate names localhost, one twenty-seven dot zero dot zero dot one, login and server, and nothing else, so a client that asks for another name or address is told which. Like the first test, it loads the server's certificate and key, which sit in our test folder next to the authority that signed them. Then it loads our client, which trusts that authority. And assert true stops the test there if either didn't load, as the checks after it would fail for the wrong reason. A domain the certificate lacks is named in the refusal, and an address it lacks gets the command to run on the server, with that address. I wanted both, as a domain and an address go through different checks in Expect Name, each with an error code of its own.
27:59 On the server, at the new step, both TLS tests pass, the old one and the new one.
28:06 Back on the laptop, with the new client built. Now it says the certificate isn't from the authority it trusts, and to copy the server's over. The message is right, as the laptop made an authority of its own when it ran the certificates script, and the server made another.
28:22 So we copy the server's authority certificate to the laptop with s c p, next to the laptop's own, which its client still trusts when it plays on the laptop's own servers.
28:33 NANOMMO TLS CA points the client at it, and that gets us a step further. The certificate doesn't name the address we asked for, and the message says which command makes one that does.
28:46 On the server, we run what it says, and the script answers that the folder has them already, and leaves them as they were, without the address. The other way it's easy to type, with the address and no folder, makes a whole new authority, in a folder named after the address, which sits next to everything else.
Names on the certificate
29:03 The certificates script gets two fixes, one for the folder it's given and one for the names. Its opening lines now say the names can be a server's domain or address. And running it again with a name the certificate lacks, or once the certificate has expired, signs a new one with all the names, from the authority it had, so the clients' copy of the authority still trusts it. The folder's check comes first, right after the script reads the folder. A case in shell matches a string against patterns, top to bottom, and the first that matches wins. We need it because a name where the folder goes would quietly make a folder of that name, with an authority of its own in it. A folder with a slash in it is a path, and we leave it alone. Anything else with a dot looks like a domain or an address, and unless that folder is there already, we refuse it, with the command that was meant, the TLS folder first. The check for certificates that are there already moves down, below the names, as it's going to compare them. Then the names, as until now, the script said the folder has them and stopped, without the address, like we saw on the server. Now it reads the names the servers' certificate has from OpenSSL's text output, on the line after the subject alternative name heading. They're written as we write them, as OpenSSL prints I P Address with a space, and sed turns it into I P with a colon. Then we go through what we were asked for, one at a time, and look for each in the list we have, with commas around both. That way, a name like server doesn't match server dot example dot com, and the ones it lacks go in lacking. A certificate also needs signing again once it's run out, which is what the handshake's message told us to do about an expired one. OpenSSL's check end with a zero says whether the certificate expires within zero seconds, and when it fails, expired is set. With nothing lacking, and nothing expired, it says the folder has them already, for these names, and stops. To sign a new certificate, it needs the authority's key, and a server that was sent the certificates without it can't, so that's an error. The new names are the ones it had, then a comma and a space before each lacking one, or the ones it had alone, for one that expired. Each name is a word of its own, so we leave lacking unquoted, and the shell splits them for printf. The lines that made a new authority each time go, and in their place, the authority is made when there's no key, and kept when there is. Keeping the authority is my favourite change of the episode, as a new server certificate from it checks out against the clients' copy, so nobody has to copy the authority again. Its key is still made with umask zero seven seven, as the authority's key signs certificates, so nobody else gets to read it. The variable made remembers which of the two it did, and again adds that the servers have to start again to use the new certificate. The last line says what it made, in which folder, and for which names. We give again a default of empty, as set dash u stops the script on a variable that isn't set.
32:02 At the new step, the script signs a new certificate for the servers, with the address on it, from the authority it had, and says to start the servers again, which we do. And the address where the folder goes is refused, with the command that was meant.
32:17 This time the login goes through, and we get the worlds, and arthur's characters. Entering Ember is refused, as Ember says it's at localhost. A world registers the address players reach it at, which is localhost unless we say, and from the laptop, localhost is the laptop. So the message says to start the world with NANOMMO public host.
32:40 So on the server, the world starts with its address, and registers with Consul as before.
32:47 And the laptop enters Ember, on the server, across the network. The login and the world's connection go over TLS, with a certificate that names the server, and the world's updates come over UDP, as they did on one machine.
Two worlds, and none
33:01 Two more things get in a newcomer's way, and the first is a second server on this machine. On port seven seven eight seven, it ends with a Civet Exception and an abort, which doesn't say which port it couldn't listen on. The metrics port, nine four six four, is Ember's, and prometheus C++ throws when it can't listen on it, before the world gets to its own port.
33:23 And with the login server up, and no world, the worlds screen says no worlds are up, without a word on what a world is, or how to start one.
33:35 In the server's main, we bring in exception, the standard library's base class for exceptions. prometheus C++ serves our metrics through CivetWeb, a small web server in C, and its exposer throws when it can't listen on its port. The exposer becomes an optional, empty to start with. CivetWeb throws when the port's taken, as by another world on this machine, which would end the server without a word on why. Emplace builds the exposer in place, inside a try block, so we can use it after the block. I don't love a try block in a code base that doesn't use exceptions, but prometheus C++ throws, so the try goes around that one call and nothing more. Checking the port first wouldn't help, as another program can take it between our check and the exposer's. When it throws, we print that the server couldn't serve metrics on that port, with CivetWeb's message from the exception's what. Then we ask whether another server is running here, as another world needs a port of its own, and NANOMMO metrics port too. And main returns one, so a script can tell it failed. The registry goes on the exposer through the optional's arrow. On the worlds screen, the worlds come from the login server, which reads them from Consul. A world is a nanommo server, which Consul lists once it's started. So under no worlds are up, a second line says to start nanommo server, then Refresh.
34:57 At the new step, the second world says the metrics port is taken, and what to set. Frost, with a port and a metrics port of its own, starts, and registers next to Ember.
35:09 And the worlds screen says to start nanommo server, then press Refresh.
A page of steps
35:18 The last piece is somewhere to find all of this. The game's docs get a getting started page, and the website shows it as Get started, with this episode next to it once it's up. It's steps, commands and tables, as you read a page like this with a terminal open next to it. Right after the clone comes the doctor, with what it installs on macOS and on Ubuntu. Further down, playing from another computer has why each step is there, and at the end, a table has the errors we met today, each with why it happens and what to do.
Wrap-up
35:51 So, today, we took a brand-new machine from a git clone to a laptop playing on it. A doctor script says what a machine is missing, with one command that installs it. The build has no warnings of ours, and Redis, MySQL and Consul listen on the server alone. The programs find their files from any folder, and a refused handshake says what's wrong with the certificate, and what to do. The certificates script adds the names you ask for, from the authority it had, and the steps are on a getting started page, in the docs and on the website.
Playing it
37:16 If you try this on a machine of your own and something gets in the way, tell me in the comments, as that's what this episode was about. And if you want to follow along with the series, subscribe to the channel. I hope you find this useful, and thanks for watching.