Upgrades & draining
This page covers moving to a new release: replacing the binary, applying schema changes, and stopping the old process cleanly.
Before you upgrade
Section titled “Before you upgrade”- Read the release notes on GitHub for the version you are moving to.
- Back up the database and the identity key. See Identity keys.
- Check that your config file has no keys the new version does not know: an unknown key stops the server at
startup.
config.example.yamlin the new release lists every key.
Upgrade the .deb
Section titled “Upgrade the .deb”VERSION=1.4.1BASE=https://github.com/stephanfeb/go-ricochet/releases/download/v${VERSION}curl -LO "$BASE/ricochet-server_${VERSION}_amd64.deb"curl -LO "$BASE/SHA256SUMS"sha256sum --check --ignore-missing SHA256SUMS
sudo apt install ./ricochet-server_${VERSION}_amd64.debThe package handles the restart:
- Before the files change, it notes whether the server is running and stops it through supervisord.
- It installs the new binary,
run.sh,health_check.shandschema.sql. - It keeps your
/etc/ricochet/config.yamland/etc/supervisor/conf.d/ricochet.conf(both conffiles) and your/etc/ricochet/env, and resetsconfig.yamlandenvto mode 640, ownerroot:ricochet. - If the server was running before, it starts it again on the new binary. A server that was stopped stays stopped.
If the restart fails, the package prints a warning pointing at supervisorctl tail ricochet stderr.
Upgrade a manual install
Section titled “Upgrade a manual install”Stop the server, replace the binary, apply the schema, start it:
sudo supervisorctl stop ricochet # or your own supervisorsudo cp ricochet_1.4.1_linux_amd64/ricochet /usr/local/bin/ricochetpsql -h localhost -U ricochet -d ricochet -f ricochet_1.4.1_linux_amd64/schema.sqlsudo supervisorctl start ricochetKeep the old binary until the new one has run cleanly.
From 1.4.0 to 1.4.1
Section titled “From 1.4.0 to 1.4.1”Nothing to do on the server: schema.sql and the config are unchanged. pkg/client gains
MarkDeliveredInFolder, so a banned peer can mark its ban notice delivered. See
Errors.
From 1.2.0 to 1.4.0
Section titled “From 1.2.0 to 1.4.0”1.3.0, 1.3.1 and 1.4.0 add moderation and the connection log. See Moderation & the connection log.
- Run
schema.sql. It adds two tables,peer_bansandpeer_connections. Without them the server still starts, but logsbans not loaded; run schema.sql to create peer_bans, refuses every ban, and warns for each connection it fails to record. - The connection log is on by default. The server now keeps, for 90 days, which IP each peer connected from.
To keep nothing, set
audit.connection_log_days: 0before you start the new binary. - Nobody may moderate until you say so.
security.moderatorsis empty by default. - Your config needs no change: both new keys are optional.
pkg/clientand the client-facing protocols are unchanged.
From 1.1.0 to 1.2.0
Section titled “From 1.1.0 to 1.2.0”1.2.0 adds transports beside UDX. An existing setup keeps working unchanged:
- Without
server.transports, the server runs UDX alone, as 1.1.0 did. To add TCP, QUIC, WebSocket or WebTransport, see Transport. schema.sqlis unchanged.- The packaged
run.shnow passesEXTERNAL_IPas--external-ipinstead of building an--external-addrsUDX address. With the default listen address it advertises the same address as before, and it covers any transport you add later. - Startup is stricter about addresses. A listen or external address that does not parse, or whose transport is
not in
server.transports, now stops the server withinvalid config: .... 1.1.0 skipped a bad external address with a warning.
Schema changes
Section titled “Schema changes”The server never changes the schema itself. Schema changes ship in schema.sql, which is written to be run again
on an existing database:
- Tables and indexes are created with
IF NOT EXISTS. - Columns added to existing tables are in an “in-place upgrades” section near the end, with
ADD COLUMN IF NOT EXISTSand, where needed, a backfill of existing rows. - The grants at the end are re-applied.
So on every upgrade, run the new release’s schema.sql against your database, as the database owner or a
superuser, before you start the new binary. Running it when nothing changed is harmless. There are no numbered
migrations and no down-migrations: to roll back, restore your database backup.
The .deb does not run schema.sql for you. It installs it at /opt/ricochet/schema.sql:
psql -h localhost -U ricochet -d ricochet -f /opt/ricochet/schema.sqlGraceful shutdown
Section titled “Graceful shutdown”On SIGTERM or SIGINT, the server shuts down in this order:
- Withdraws from load balancing.
/readyzstarts returning 503 with"draining":true, and the server logsops surface draining — /readyz now reports unready. - Waits
ops.drain_delay(default 0) while still serving, loggingdraining before shutdown. This gives a load balancer polling/readyztime to take the instance out of rotation. - Refuses new requests with a 503 in each protocol’s own error format, and waits up to
ops.shutdown_timeout(default 5 s) for requests already in flight. It logsin-flight requests drained, orshutdown timeout reached with requests still in flightif the timeout ran out. - Tears down background services, the libp2p host, the ops listener, and finally the database pool, and
logs
server stopped.
A second signal during this sequence forces an immediate exit with code 130 (SIGINT) or 143 (SIGTERM), and
logs forced shutdown: second signal arrived before the graceful stop finished. A shutdown that fails exits with
code 1.
ops: drain_delay: 20s # behind a load balancer: a couple of probe intervals shutdown_timeout: 5sSet your supervisor’s kill timeout above drain_delay + shutdown_timeout plus a few seconds for teardown. The
.deb’s supervisord config waits 30 seconds (stopwaitsecs=30), which covers the defaults; raise it if you set a
long drain_delay.
Check it works
Section titled “Check it works”ricochet --version # or /opt/ricochet/ricochet_server --versioncurl -s http://127.0.0.1:9090/readyzgrep 'running. Peer ID' /var/log/ricochet/stdout.log | tail -n 1The startup line shows the new version, and the peer ID should be unchanged.
Troubleshooting
Section titled “Troubleshooting”- The new version will not start:
parse config file: ... field X not found: the key was removed or renamed. Delete or rename it. Alogging:block from before v1.0.0 is a common case; delete it. - Errors about a missing column after the upgrade: the new
schema.sqlwas not applied. Run it. - The server was running before the
.debupgrade and is now stopped: the restart failed. Checksupervisorctl tail ricochet stderr, fix the cause and start it. - Clients see a burst of failures during each restart: set
ops.drain_delayand point the load balancer’s health check at/readyz.