Step 1: one box¶
layouts/app.toml serves every later step, by its environment:
database = "${DATABASE_URL:-sqlite:///guestbook.db}"
[processes.web]
services = ["web", "book"]
url = "${MYXO_URL_WEB:-unix:run/web.sock}"
bind = "${MYXO_BIND:-127.0.0.1}"
instances = "${WEB_INSTANCES:-1}"
[processes.worker]
services = ["moderation"]
[services.web]
host = "${MYXO_BIND:-127.0.0.1}"
port = "${PORT:-8000}"
[services.book]
database = "${DATABASE_URL:-sqlite:///guestbook.db}"
The layout now has two processes: web, which runs web and book, and worker, which runs moderation. The worker calls book in the web process. A process that others call needs a url: on one machine, a Unix socket, run/web.sock, which only the application's user can open, and no port to allocate. SQLite serves both processes, since they run on one host.
myxo check finds what would stop a layout, without starting anything: a missing setting, a mutable message, an import from another package that bypasses an interface. It cannot know where the layout will run, so the limits of a target come from the command that runs it: myxo up runs one instance of each process, for instance. myxo up runs every process of the layout, after the migrations, restarts one that exits, and stops them all on Ctrl-C:
$ myxo check layouts/app.toml
layouts/app.toml: ok
$ myxo migrate layouts/app.toml
$ myxo up layouts/app.toml
For a server without a platform, the export command writes the files an operator installs, here systemd's:
$ myxo export layouts/app.toml systemd --name guestbook --out units
units/guestbook-migrate.service
units/guestbook@.service
units/guestbook.target
units/env.example
A one-shot unit runs the migrations. A template unit runs each process after them. A target starts them all. Every unit works in /var/lib/guestbook, a directory of the application's user alone, so the SQLite file and the sockets are found there by every unit, and kept across reboots. env.example lists the variables the layout reads, with their defaults, for the operator to fill in.
Next, read step 2, a real database.