Updates
On a Docker server that was built from a Git checkout, an administrator can update Marginalia from the Update tab of the Admin page, without logging in to the server: the server pulls the newest version of the branch its checkout is on, builds the application and the bundled plugins and restarts.
It needs a small program on the server, the update watcher, which is
The Update tab
The server follows the branch that is checked out there, whatever it is: to move an installation to another branch,
git switch it in the checkout on the server; the tab shows the new branch after the next look.
The same can be done from a script, with an API key that has the access Update the installation: read the status, ask for an update and read the log (see the developer manual).
What an update does
-
The new version is built:
git pull, the plugins, the image. This takes several minutes and Marginalia keeps running while it lasts. The tab shows The update is running; Log shows how far it is. -
Marginalia is stopped, the new plugins are copied into
data/extensions(replacing the installed ones) and the new version starts. This takes a minute or two (see Health). Everybody who is working is interrupted, and whatever is being generated is stopped: the confirmation tells you how many jobs run at that moment, so pick a quiet time. -
The database is upgraded when the new version starts, after a copy of it was saved. Make a database backup of your own first as well.
When the build fails, nothing is stopped: the version from before keeps running, Last update says failed and the log says why. The next update builds again, also when there is nothing new to pull.
Setting up the watcher
Marginalia runs inside a container and can reach neither the Git checkout nor Docker; giving it that access would
make everybody who gets into the application an administrator of the server. So it only asks: it writes a file into
its data folder, and the watcher, which runs on the server outside the container, does
the work. The watcher is the script tools/update-watcher/watch.sh of the checkout; all it ever runs is rebuild.sh
of the same checkout (see Automatic updates).
Linux with systemd
In the checkout on the server (the folder with docker-compose.yml):
sudo tools/update-watcher/install.sh
It installs and starts three units:
Open Admin → Update and click Refresh: the tab shows the branch and the newest commit. That is all.
systemctl status marginalia-update.service shows the last run and journalctl -u marginalia-update.service its
output (the same text as Log, and the reason when the watcher itself could not work). The units contain the path
of the checkout: after moving the checkout, run install.sh again.
Without systemd (cron)
Run the watcher every minute; it does nothing when nobody asked for an update and it looked at the remote less than 15 minutes ago, so this costs nothing:
* * * * * /path/to/Marginalia/tools/update-watcher/watch.sh >> /var/log/marginalia-update.log 2>&1
Put the line into the crontab of root (sudo crontab -e), or of another user, see below. An update then starts
within a minute of the click.
Settings
The watcher reads these environment variables (with systemd: sudo systemctl edit marginalia-update.service and
Environment=NAME=value lines under [Service]):
Who the watcher runs as
By default the watcher runs as root: it has to use Docker and to write into the data folder, which belongs to the user of the container. Git itself is run as the owner of the checkout, so the files of Git stay theirs.
The watcher runs what the branch contains (rebuild.sh, the Dockerfile), as every update by hand does: follow only
a repository you trust, and keep the checkout writable only for its owner, because whoever can change rebuild.sh or
watch.sh there runs commands as the user of the watcher.
With --user USER (or the crontab of that user) it runs as somebody else. That user must be allowed to use Docker
(which on most systems is as much as root), must own the checkout, and must be able to write into data/update and
data/extensions, which normally belong to the user of the container.
Windows and macOS
There is no ready watcher for Docker Desktop. Update with rebuild.bat / rebuild.sh by hand or from a scheduled
task, see Automatic updates.
Troubleshooting
The files of the watcher are in update of the data folder: status.properties (what the tab shows), update.log
(the last update) and, for a moment, request.