Deployment and upgrades
This page takes katana from a binary that passes --test to a service you can leave running and upgrade without surprises. It covers which release build to install, where the files go, a systemd template unit that runs one katana process per config file, how to read the logs, an upgrade procedure that restarts one instance before the others, how to roll back, what to test after a restart, and how memory and file descriptors grow with load.
It is written for operators of katana 6.0.0 on x86_64 Linux with systemd. The commands use two example instances, xboard and helium, one per panel. If you have not run katana yet, start with the quick start; the general service behaviour that katana shares with etemenanki-app (exit codes, signals, log filters) is on Running in production.
What a production node looks like
Section titled “What a production node looks like”flowchart LR SD["systemd: katana@xboard"] --> P1["katana process"] SD2["systemd: katana@helium"] --> P2["katana process"] P1 --> C1["/etc/katana/config-xboard.toml"] P2 --> C2["/etc/katana/config-helium.toml"] P1 -- "stdout" --> J["journald"] P2 -- "stdout" --> J P1 -- "poll and report" --> PA["Panel A"] P2 -- "poll and report" --> PB["Panel B"]
- One binary,
/usr/local/bin/katana, shared by every instance. - One config file per instance. Each file may hold several
[[node]]entries. - One systemd template unit,
katana@.service. The instance name picks the file. - Logs go to standard output, and journald keeps them.
- katana writes no files, unless a node sets
handoff_dir: then it creates that directory if it is missing, and one socket in it for each stream node (Handoff sockets). It needs read access to its config, certificates, geodata, rule list and[dns] ca_fileif you set one, and/etc/groupwithhandoff_group, and nothing else on disk.
Choose a release build
Section titled “Choose a release build”Every katana release tag publishes two x86_64 Linux executables, each with a SHA-256 checksum file. VERSION is the tag, for example v6.0.0.
katana-VERSION-linux-x86_64-gnu |
katana-VERSION-linux-x86_64-musl |
|
|---|---|---|
| Linking | Dynamically linked against the host’s glibc. OpenSSL is compiled in. | Fully static: no program interpreter, no shared libraries. |
| Host requirement | A glibc at least as new as the build host’s, Ubuntu 22.04 (glibc 2.35). | Any x86_64 Linux, including Alpine. |
[dns] backend = "system" |
glibc’s getaddrinfo, which follows /etc/nsswitch.conf and its NSS modules. |
musl’s resolver, which reads /etc/hosts and /etc/resolv.conf directly. |
| Memory allocator | glibc’s malloc |
mimalloc, which katana installs as its global allocator in place of musl’s malloc |
The release workflow checks both properties it promises: it fails if the -gnu binary loads libssl or libcrypto dynamically, and it fails if the -musl binary has any dynamic dependency at all.
How to pick:
| Host | Build |
|---|---|
| Ubuntu 22.04 or later, Debian 12 or later | -gnu, or -musl if you prefer one binary for every host |
| Debian 11, Ubuntu 20.04, RHEL 9 and its rebuilds (glibc 2.34), Alpine | -musl |
Resolution depends on NSS modules (for example nss-resolve, LDAP or a custom hosts: line) |
-gnu |
| Not sure | -musl |
The two builds also differ in which allocator serves every buffer and user table. The -gnu build keeps glibc’s malloc. The -musl build replaces musl’s own malloc, which takes one global lock for every allocation and free, with mimalloc, compiled into the binary. Memory figures from one build do not predict the other. Pick one build and keep it across upgrades, so that a before-and-after comparison measures the new version and not the new allocator.
To see whether a host can run the -gnu build, run the binary’s --version. A glibc that is too old fails right there with version `GLIBC_2.xx' not found, before any config is involved.
Download and verify
Section titled “Download and verify”Download the binary and its .sha256 file into the same directory, from the release page or with the GitHub CLI. OWNER is the account that hosts the katana repository; you need read access to it. The .sha256 file names the asset by its original file name, so run the check in the download directory, before you rename or move anything:
VERSION=v6.0.0BUILD=musl # or gnugh release download "$VERSION" --repo OWNER/katana \ --pattern "katana-$VERSION-linux-x86_64-$BUILD*"sha256sum -c "katana-$VERSION-linux-x86_64-$BUILD.sha256"katana-v6.0.0-linux-x86_64-musl: OKAnything other than OK means the download is incomplete or damaged: download it again and do not install it. The checksum comes from the same CI job as the binary, so it detects corruption, not a substituted file. The assets are plain executables, not archives. Install walks through the same download for a first installation.
Lay out the files
Section titled “Lay out the files”katana has no built-in file locations. It reads the config from -c and every other file from the path written in the config. This layout keeps everything for all instances under /etc/katana:
Directoryusr/local/bin/
- katana the binary every instance runs
- katana.prev the previous version, kept after an upgrade for rollback
Directoryetc/
Directorykatana/ owner root, group katana, mode 0750
- config-xboard.toml instance
katana@xboard, mode 0640 - config-helium.toml instance
katana@helium, mode 0640 Directorycerts/
- fullchain.pem certificate chain for TLS and Hysteria 2 nodes
- privkey.pem private key, mode 0640, group katana
- geoip.dat only if a route rule uses
geoip - geosite.dat only if a route rule uses
geosite - rules.txt local audit rules, only if you set
rule_list_path
- config-xboard.toml instance
Directorysystemd/
Directorysystem/
- katana@.service the template unit below
Directorykatana@xboard.service.d / optional per-instance overrides
- override.conf
Write every path in the config as an absolute path. katana opens a relative path such as geoip = "geoip.dat" relative to the process’s working directory, not relative to the config file, so the check fails when katana does not run in the config’s directory:
configuration error: node 1: building route failed: No such file or directory (os error 2)A node that points at the layout above looks like this:
[log]level = "info"
[[node]]panel_type = "NewV2board"
[node.api]host = "https://panel.example.com"node_id = 1key = "replace-with-the-panel-key"node_type = "V2ray"rule_list_path = "/etc/katana/rules.txt"
[node.controller]listen_ip = "0.0.0.0"update_periodic = 60
[node.controller.cert]mode = "file"cert_file = "/etc/katana/certs/fullchain.pem"key_file = "/etc/katana/certs/privkey.pem"
[node.route]default = "direct"geoip = "/etc/katana/geoip.dat"geosite = "/etc/katana/geosite.dat"
[[node.route.rule]]outbound = "block"geoip = ["private"]Create the service user and set the ownership once:
sudo useradd --system --no-create-home --shell /usr/sbin/nologin katanasudo install -d -o root -g katana -m 0750 /etc/katana /etc/katana/certssudo chown root:katana /etc/katana/*.toml /etc/katana/certs/*.pemsudo chmod 0640 /etc/katana/*.toml /etc/katana/certs/*.pemThe config files hold the panel keys, so keep them unreadable to other users. katana only reads these files, so neither the directory nor the files need to be writable by katana.
Run katana under systemd
Section titled “Run katana under systemd”The template unit
Section titled “The template unit”Save this as /etc/systemd/system/katana@.service. The text after @ in the instance name selects the config file: katana@xboard runs /etc/katana/config-xboard.toml.
[Unit]Description=katana node agent (%i)After=network-online.targetWants=network-online.target
[Service]Type=execUser=katanaGroup=katanaWorkingDirectory=/etc/katanaEnvironment=NO_COLOR=1# Only for [dns] backend "tls" or "https" without ca_file:# Environment=SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crtExecStartPre=/usr/local/bin/katana --test -c /etc/katana/config-%i.tomlExecStart=/usr/local/bin/katana -c /etc/katana/config-%i.tomlRestart=on-failureRestartSec=5sLimitNOFILE=1048576
# Only if a panel assigns a node port below 1024.AmbientCapabilities=CAP_NET_BIND_SERVICECapabilityBoundingSet=CAP_NET_BIND_SERVICE
NoNewPrivileges=yesProtectSystem=strictProtectHome=yesPrivateTmp=yesPrivateDevices=yesProtectKernelTunables=yesProtectKernelModules=yesProtectControlGroups=yesRestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX AF_NETLINKRestrictNamespaces=yesLockPersonality=yesSystemCallArchitectures=native
[Install]WantedBy=multi-user.targetThen start the instances and follow their logs:
sudo systemctl daemon-reloadsudo systemctl enable --now katana@xboard katana@heliumjournalctl -u 'katana@*' -fWhat each setting does
Section titled “What each setting does”| Setting | Why |
|---|---|
After= and Wants=network-online.target |
Each node asks its panel for its settings right after start. A node whose first attempt fails retries by itself, 1 s later at first and then with a wait that doubles up to 60 s, or up to update_periodic if that is shorter. Starting after the network and DNS are up avoids a burst of first-attempt errors in the journal, and a delay of up to a minute: by the time the network is ready, a node’s wait for its next attempt may have grown that long. See Restarts and node failures. |
ExecStartPre=… --test |
Refuses to start a file that does not parse, has an unknown key, holds no [[node]], names SSPanel or an unknown panel_type, an unknown node_type, outbound or geodata code, repeats an outbound tag, has an [[outbound]] or [dns] that does not build, points at a geodata file or ca_file it cannot read, has invalid Hysteria 2 settings, or sets on a helium node a key that its panel describes. A plain start would skip a node it cannot build and run the rest; the check makes a broken node fail the whole start, where you notice it. --test prints Configuration OK into the journal, after the warning for a WireGuard outbound that several nodes route to, if there is one. What --test checks lists the order. |
Restart=on-failure |
Restarts katana after it exits with status 1, or after a signal other than SIGTERM, SIGINT, SIGHUP or SIGPIPE kills it, for example SIGKILL from the out-of-memory killer. It does not restart after systemctl stop or SIGHUP. A failed ExecStartPre= counts as a failure too: with RestartSec=5s, systemd’s default start limit (5 starts in 10 seconds) is never reached, so a broken config is retried every 5 seconds, logging the same error, and the instance comes up on its own once you fix the file. |
LimitNOFILE=1048576 |
Every client connection holds a descriptor, and usually a second one for its outbound. systemd’s default soft limit of 1024 runs out quickly. See File descriptors. |
AmbientCapabilities=CAP_NET_BIND_SERVICE |
Lets the unprivileged katana user bind ports below 1024. See Ports below 1024. |
Environment=NO_COLOR=1 |
katana writes ANSI colour codes even when standard output is not a terminal. NO_COLOR turns them off, so the journal shows plain text instead of sequences like [2m. |
WorkingDirectory=/etc/katana |
A safety net for relative paths in a config. Absolute paths do not need it. |
ProtectSystem=strict and the other hardening lines |
katana only reads files and opens network sockets, so the file system can be read-only for it and the rest of the system hidden. A node with handoff_dir needs one writable directory, which Handoff sockets adds. Remove a line if your setup needs what it takes away. |
Leave TimeoutStopSec= at its default of 90 seconds. On SIGTERM each node closes its listener and connections and then sends one last traffic report. Each report can take up to api.timeout seconds (5 when unset), and the nodes do this in parallel. If systemd has to send SIGKILL first, the traffic of the last poll period is lost.
Ports below 1024
Section titled “Ports below 1024”The panel, not the config file, decides each node’s port. The one exception is a Hysteria 2 node on Xboard or V2board that sets [node.hysteria].port, which listens on that port without asking the panel. A node assigned port 443 needs CAP_NET_BIND_SERVICE. Without it the node logs the error below and keeps retrying, while the process and every other node keep running:
ERROR katana::manager::node: node 1: initial start failed: inbound V2ray_0.0.0.0_443: binding <address> failed: Permission denied (os error 13); retrying in 1sThe inbound tag is built from the node type, listen_ip as written and the port; Listen address and node tag explains it.
The retries cannot succeed on their own. A process receives its capabilities when it starts, so after you grant the right, restart the instance.
There are three ways to grant the right:
| Method | How | Note |
|---|---|---|
| Unit capability | AmbientCapabilities= and CapabilityBoundingSet=, as in the unit above |
Recommended. It belongs to the service, so it survives binary upgrades. |
| File capability | sudo setcap cap_net_bind_service=+ep /usr/local/bin/katana |
Stored on the file. The upgrade procedure below installs a new file, which has no capability, so every low-port node fails after the next restart. Avoid it. |
| System-wide | sysctl net.ipv4.ip_unprivileged_port_start=443 |
Lets every user on the host bind those ports. |
If every node uses a port of 1024 or above, delete the AmbientCapabilities= line and leave CapabilityBoundingSet= empty, so the process holds no capability at all.
Handoff sockets
Section titled “Handoff sockets”A node with handoff_dir set also listens on a Unix socket, <handoff_dir>/<port>.sock, or <handoff_dir>/<listen_ip>-<port>.sock for a node on one address, on which a relay running on the same host hands over the TCP connections it accepted for the node (Handed-over connections). File permissions alone decide who may connect:
| What | Mode | Group | Set by |
|---|---|---|---|
| The socket, one per stream node | 0660 |
handoff_group, or katana’s own group without it |
katana, each time it binds the socket |
The directory handoff_dir |
0750 |
handoff_group, or katana’s own group without it |
katana, but only when it creates the directory. A directory that already exists keeps its mode and group: give it the relay’s group and a mode that lets the group in yourself |
For the relay to connect and katana to bind:
- The relay’s user is in
handoff_group. Modes0750and0660let the group enter the directory and connect to the socket, and nobody else apart from katana. - katana’s user is in
handoff_grouptoo, unless katana runs as root. katana gives the directory and the socket the group itself, and a process can give a file only a group it belongs to. Without the membership the bind fails withOperation not permitted (os error 1). A process takes its groups when it starts, so restart the instance after you add it. - katana can create the directory. katana creates
handoff_diras thekatanauser. A missing parent is created as well, but without the relay’s group or a mode that lets it in, so puthandoff_dirdirectly inside a directory that exists and that the relay can enter.
handoff_group names the group as /etc/group lists it. katana reads that file itself, so a group that only an NSS module knows, from LDAP for example, is not found.
Under the template unit, ProtectSystem=strict mounts the file system read-only for katana, and a handoff_dir outside a writable path fails with Read-only file system (os error 30). Give each instance a runtime directory with sudo systemctl edit katana@xboard:
[Service]RuntimeDirectory=katana-%isystemd creates /run/katana-xboard, owned by katana, before each start and removes it after each stop. Name it per instance with %i, so that each instance has a directory of its own and stopping one leaves the others’ alone. Put the sockets in a subdirectory, which katana then creates with the relay’s group:
[node.controller]handoff_dir = "/run/katana-xboard/handoff"handoff_group = "relay"relay stands for the group the relay runs as. Add katana to it and restart the instance:
sudo usermod -aG relay katanasudo systemctl restart katana@xboardThe start log names each socket, node 1: listening on [::]:443, and for handed-over connections on /run/katana-xboard/handoff/443.sock; that is the path the relay connects to. A node with listen_ip = "203.0.113.5" logs node 1: listening on 203.0.113.5:443, and for handed-over connections on /run/katana-xboard/handoff/203.0.113.5-443.sock instead. The rest of the unit already fits:
RestrictAddressFamilies=allowsAF_UNIX, which the sockets need.ExecStartPre=… --testcheckshandoff_dirandhandoff_group, and looks the group up in/etc/group, before the instance starts. It neither creates the directory nor binds a socket.PrivateTmp=yesgives katana a/tmpof its own, so do not puthandoff_dirunder/tmp: the relay would not see it.
A socket that cannot be bound keeps its node from coming up. The node logs initial start failed: inbound <tag>: binding handoff:<path> failed: …; retrying in Ns and retries, like any node whose bind fails.
Restarts and node failures
Section titled “Restarts and node failures”Restart=on-failure watches the process, not the nodes inside it. katana exits with status 1 only when it cannot load the config, has no [[node]], or could not build any node at all, which it logs as no nodes could be started. A node that does not build at start, for example because a rule names an unknown outbound, is skipped with a node <id>: … error while the others run. A node that builds but cannot come up retries by itself instead: its panel is unreachable at start, katana refuses the node the panel describes, such as one with a port outside 1 to 65535, the panel returns no user list, or its port is taken. It logs an error for every failed attempt, and systemd still shows the unit as active (running):
ERROR katana::manager::node: node 2: node_info failed: …; retrying in 1sERROR katana::manager::node: node 3: initial start failed: inbound Trojan_0.0.0.0_8443: binding <address> failed: Address already in use (os error 98); retrying in 4sThe first retry comes 1 s after the first failure. Each further wait doubles, up to 60 s, or up to update_periodic if that is shorter. Every attempt asks the panel afresh and builds the listener again, so the node comes up at its next attempt once the cause is gone: the panel answers, the port is free, the certificate is readable. Saving an edit to the node’s [[node]] entry starts the next attempt at once. Restart the instance only for a change that the process picks up at start, such as a unit setting or a capability.
After every start, check that each node logged its listening on line, as described in Smoke test.
Run several instances
Section titled “Run several instances”One katana process can serve many nodes: repeat [[node]] in one file. Split the nodes across instances when you want:
- to restart one group of nodes without dropping the others’ connections, for example one instance per panel;
- to upgrade one group first and keep the rest on the old binary until it has proved itself;
- separate log streams,
journalctl -u katana@xboardandjournalctl -u katana@helium.
Instances do not coordinate with each other. Keep these rules:
| Rule | Why |
|---|---|
| Serve each panel node from exactly one instance. | The panel gives the node one port, so the instance that starts second cannot bind it. It logs initial start failed: inbound <tag>: binding <address> failed: Address already in use (os error 98); retrying in …s for that node and keeps retrying, so it takes the port at its next attempt after the other instance releases it, for example when that instance stops. |
Keep ports unique across instances whose listen_ip values overlap. 0.0.0.0, the default, overlaps every IPv4 address and, on a dual-stack host where it binds [::], every IPv6 address too. |
The panel assigns ports per node, and katana cannot see another instance’s ports. The second bind fails with Address already in use (os error 98), and that node keeps retrying. A Hysteria 2 node listens on UDP, so it can share a number with a TCP node. |
| Give each WireGuard key to one node in one instance. | Every node that routes to a WireGuard outbound brings up its own tunnel, whether the nodes share a process or not. Two tunnels with the same private key to the same peer take the peer’s session from each other. Within one file katana warns about it (wireguard outbound <tag> is routed to by N nodes …); across instances nothing warns. |
| Expect a little more memory. | Each process has its own runtime. The nodes cost about the same wherever they run, because every node builds its own outbounds, resolver and user table either way. |
An instance applies only edits to its own config file. Saving one instance’s file changes nothing in the others, even though they share /etc/katana.
For a setting that only one instance needs, use a drop-in instead of editing the template:
sudo systemctl edit katana@xboard[Service]Environment=RUST_LOG=info,katana=debugRestart the instance to apply it: sudo systemctl restart katana@xboard.
katana writes one line per event to standard output, and journald stores it under the unit’s name. Each line has a UTC timestamp, the level, the module and the message:
2026-09-24T08:00:01.512304Z INFO katana::manager::node: node 1: listening on [::]:4432026-09-24T08:00:01.733918Z WARN katana::manager::node: node 2: report 6f9619ff-8b86-d011-b42d-00c04fc964ff: …2026-09-24T09:14:52.004816Z INFO katana::runtime: shutting downReading the journal
Section titled “Reading the journal”journalctl -u katana@xboard -f # follow one instancejournalctl -u 'katana@*' --since '10 min ago' # every instancejournalctl -u 'katana@*' -b -g 'WARN|ERROR' # problems since bootjournalctl -u katana@xboard -g 'listening on' -n 50 # which nodes are upChoosing the level
Section titled “Choosing the level”The log filter comes from the first of these that is set:
- the
RUST_LOGenvironment variable, if it parses; [log].levelin the config file;info.
Set RUST_LOG in a drop-in, as shown in Run several instances, when you want a level for one run without touching the config. Change [log].level in the config when you want it to last: katana applies a new [log].level at once, without a restart and without dropping connections, and from then on it replaces the RUST_LOG filter. Useful values:
| Value | What you get |
|---|---|
info |
Startup, listener, reload and shutdown lines, warnings and errors. The default, and the right level for production. |
warn |
Warnings and errors only. |
info,katana=debug |
katana’s own modules at debug. |
info,etemenanki_supervisor=debug |
The runtime’s connection handling at debug, including connections refused by a built-in limit. |
debug |
Every module at debug, including the kernel’s per-connection errors. Verbose on a busy node. |
At debug, a busy node can exceed journald’s rate limit, and journald then drops lines and logs Suppressed N messages from katana@xboard.service. Raise the limit for the instance while you debug, with LogRateLimitIntervalSec=0 in its drop-in, and remove it afterwards. Running in production explains the filter syntax in full.
Lines worth watching
Section titled “Lines worth watching”| Line | Level | Meaning |
|---|---|---|
node N: listening on IP:PORT |
INFO | The node is serving. With listen_ip = "0.0.0.0" on a dual-stack host the address is [::], which takes IPv4 clients too. A node with a handoff socket adds , and for handed-over connections on PATH. |
node N: device limit on, IP ban after …; gRPC connections closed after … or node N: device limit off, no IP ban; … |
INFO | Logged when the node starts and when an edit changes these settings. See Device limits and IP bans. |
node N: VMess clock check off |
INFO | The node accepts VMess clients whose clocks are wrong (disable_vmess_clock_check = true). |
banned IP for Ns after N failed authentications |
INFO | An address kept failing to authenticate and is banned. For an IPv6 client the line names its whole /64, such as 2001:db8:1:2::/64, which the ban covers. Many of these behind a relay mean the relay sends no PROXY protocol v2 header and enable_device_limit should be off. Behind a reverse proxy in front of a WebSocket node, set real_ip_header and real_ip_from instead; see Device limits and IP bans. |
node N: node_info failed: …, node N: panel returned no node info, node N: user_list failed: …, node N: panel returned no user list, node N: initial start failed: …, each ending in ; retrying in Ns |
ERROR | The node is not up yet and retries after N seconds. The wait doubles from 1 s up to 60 s, or up to update_periodic if that is shorter. |
node N: node_info: …, node N: user_list: … |
WARN | A poll could not reach the panel, or katana refused the node settings it read (node_info: parse UniProxy config response: …). The node keeps its last settings and users. |
node N: report ID: … |
WARN | A traffic report failed. |
accept error, backing off 100ms: Too many open files (os error 24) |
WARN | The descriptor limit is reached. Raise LimitNOFILE=. |
cannot read rule_list_path PATH: … |
WARN | The local audit rule list is missing or unreadable by katana. The node runs without the local rules until a later read succeeds, at a later poll. |
wireguard outbound TAG is routed to by N nodes (…): each brings up its own tunnel with the same key, and the peer keeps only one of them at a time |
WARN | Logged at start, by --test and on every reload. Give each node that needs WireGuard its own key; see Every node builds its own outbounds. |
IPv6 sockets here take IPv6 alone (net.ipv6.bindv6only), so listen_ip 0.0.0.0 serves IPv4 only |
WARN | The host’s net.ipv6.bindv6only is set, so 0.0.0.0 stays an IPv4-only bind. Logged once. |
config reload failed, keeping current: …, reload: node …: …; keeping current config |
ERROR | An edit to the config file was rejected as a whole, for example because one node names an unknown node_type or a rule names an unknown outbound. None of the edit is applied, and every node keeps running as it was. |
reload: outbound pool rebuilt |
INFO | An edit to [[outbound]] or [dns] was applied. Every node rebuilt its outbounds and dropped all its connections. |
shutting down |
INFO | katana received SIGINT or SIGTERM. |
Upgrade
Section titled “Upgrade”A restart of an instance drops every connection on it, and its nodes are unreachable for a few seconds while the old process sends its last reports and the new one fetches its nodes from the panel. Clients reconnect on their own. The procedure below makes sure the new binary accepts every config before anything stops, keeps the old binary for a rollback, and exposes only one instance to the new version until it has passed a smoke test.
flowchart TB
D["Download and verify the checksum"] --> T{"--test passes for every config?"}
T -- no --> X["Stop here, the old binary keeps running"]
T -- yes --> K["Keep the old binary as katana.prev"]
K --> I["Install the new binary by rename"]
I --> C["Restart one instance"]
C --> W{"Nodes listening, client works, traffic reported?"}
W -- no --> R["Roll back"]
W -- yes --> A["Restart the other instances"]
A --> M["Watch memory for a day"]
-
Record a baseline. Note each instance’s memory, and run your smoke test against the old version, so that you have something to compare with:
Terminal window systemctl show -p MemoryCurrent katana@xboard katana@helium -
Download and verify the new release, as in Download and verify. Use the same build,
-gnuor-musl, as the running one. -
Stage the binary next to the old one under a temporary name, and check that it runs on this host:
Terminal window sudo install -m 0755 "katana-$VERSION-linux-x86_64-$BUILD" /usr/local/bin/katana.new/usr/local/bin/katana.new --version -
Test every config with the new binary, as the service user. A new version may reject a key the old one accepted, and katana rejects unknown keys:
Terminal window sudo -u katana sh -c 'for f in /etc/katana/config-*.toml; doprintf "%s: " "$f"/usr/local/bin/katana.new --test -c "$f" || echo FAILEDdone'The loop runs as
katanaas a whole, so the file list comes from a directory that only root and thekatanagroup can read. Every file must printConfiguration OK. If one fails, stop here and fix the config first; the running instances are untouched. Running askatanaalso catches files the service user cannot read, such as geodata or the private key of a Hysteria 2 node on Xboard or V2board.--testdoes not read the certificates of other nodes or the rule list; the smoke test covers those. -
Keep the current binary for a rollback:
Terminal window sudo cp -p /usr/local/bin/katana /usr/local/bin/katana.prev -
Install the new binary by renaming it over the old one:
Terminal window sudo mv -f /usr/local/bin/katana.new /usr/local/bin/katanaDo not
cponto/usr/local/bin/katana. Linux refuses to open a running executable for writing, so the copy fails withText file busy. A rename only replaces the directory entry: running processes keep the old file, and the next start uses the new one. -
Restart one instance and watch it come up:
Terminal window sudo systemctl restart katana@xboardjournalctl -u katana@xboard -fExpect
Configuration OKfrom the start check, then onenode N: listening on …line for every node, and noERRORlines. -
Smoke-test that instance for at least one poll period,
update_periodicseconds (60 by default), so that the first traffic report has been sent. Follow Smoke test and compare with the baseline. -
Restart the remaining instances, one at a time or together:
Terminal window sudo systemctl restart katana@helium -
Keep watching memory and the journal for the next day. See Memory for what to expect.
Roll back
Section titled “Roll back”To go back to the previous version, check that it still accepts the configs, rename it into place and restart the instances that run the new one:
sudo -u katana sh -c ' for f in /etc/katana/config-*.toml; do printf "%s: " "$f" /usr/local/bin/katana.prev --test -c "$f" || echo FAILED done'sudo mv -f /usr/local/bin/katana.prev /usr/local/bin/katanasudo systemctl restart katana@xboardThe --test step matters if you added a key during the upgrade that only the new version knows, such as katana 6’s enable_mtls. The old version fails the parse on it as an unknown key and, with the unit above, refuses to start; remove the key first. A helium node’s file has to go back to its katana 4 form as well, with its node_type. A rollback drops the instance’s connections once more, like any restart.
The rename consumes katana.prev. Copy it first (sudo cp -p /usr/local/bin/katana.prev /usr/local/bin/katana.prev2) if you want to keep it around.
Smoke test
Section titled “Smoke test”A passing --test shows that the file is valid. It does not contact the panel, bind a port, read the rule list, or read the certificate of any node other than a Hysteria 2 node on Xboard or V2board. Only a real start shows that a node works.
To read only the lines of the current run, and not those of the process before the restart, filter on the run’s systemd invocation ID:
id=$(systemctl show -p InvocationID --value katana@xboard)journalctl _SYSTEMD_INVOCATION_ID="$id" -g 'listening on|WARN|ERROR'These checks, in order, take a few minutes:
| Check | How | Expected |
|---|---|---|
| Every node is up | The current run’s journal, as shown above | One listening on line per node, with the port the panel assigned, and no ERROR line |
| The ports are bound | sudo ss -ltnp | grep katana (TCP) and sudo ss -lunp | grep katana (Hysteria 2) |
Each node’s port, owned by katana |
| A client connects | Use a real client with a test user’s subscription from the panel, and open an HTTPS site through it | The page loads. For TLS nodes, the client accepts the certificate |
| Routing works | Through the client, visit a destination one of your rules sends to block or to a named outbound |
Blocked, or leaving through the expected exit |
| UDP works | If the node relays UDP, run a DNS lookup or another UDP application through the client | An answer comes back |
| Traffic is reported | Download a file of known size through the client, then wait update_periodic seconds |
The test user’s usage in the panel grows by a little more than that size, times the node’s traffic rate. katana counts the protocol stream, so framing and handshakes add a little |
| No new warnings | journalctl -u katana@xboard --since '15 min ago' -g 'WARN|ERROR' |
Nothing new compared with the baseline |
A few notes on these checks:
- katana logs nothing when a traffic report succeeds, only when one fails. The panel is where you confirm it.
- Some panels apply reports in a background queue, so the panel’s figure can trail the report by a little. Xboard, for example, hands each report to a queue job, which needs its queue worker running.
- Run the same client tests against the old version before the upgrade. Comparing two runs finds differences faster than judging one run by itself.
- If a TLS node has no
listening online, check its certificate paths and permissions. For every node but a Hysteria 2 node on Xboard or V2board, the listener build is the first time katana reads them, and a failure shows up asinitial start failed: …; retrying in …s, not in--test. The node reads the files again at every retry, so it comes up once they are in place and readable.
Certificate renewal
Section titled “Certificate renewal”katana reads each node’s certificate and key when the node starts and again at every poll. A renewal needs no restart: new connections get the new certificate at the node’s next poll, within update_periodic seconds, and open connections continue.
Your ACME client’s deploy hook only has to put the new files in place, readable by the katana group. Write each file under a temporary name in the same directory and rename it over the old one, so that a poll never reads a half-written file:
cd /etc/katana/certsinstall -m 0640 -o root -g katana "$RENEWED_LINEAGE/fullchain.pem" fullchain.pem.newinstall -m 0640 -o root -g katana "$RENEWED_LINEAGE/privkey.pem" privkey.pem.newmv -f privkey.pem.new privkey.pemmv -f fullchain.pem.new fullchain.pemRENEWED_LINEAGE is the variable certbot sets for a deploy hook; other ACME clients name the new files differently. Pointing cert_file and key_file at new paths instead also works, but that edit drops the node’s connections.
Resources
Section titled “Resources”Memory
Section titled “Memory”Plan memory per node, and per user on each node:
- Users. Each node builds its own table of its users, with each user’s key material and traffic counters. Memory grows with the number of users, multiplied by the number of nodes that serve them. A user who can use ten nodes is held ten times.
- Connections. Each open connection holds its buffers, and each flow it relays holds its outbound’s.
- Nodes. Every node builds its own outbounds and resolver, with its own cache, from the shared
[[outbound]]and[dns]sections. A WireGuard outbound is a tunnel with its own buffers, brought up once for each node that routes to it.
Memory therefore rises after a start, as clients connect, before it levels off. Judge a new version by the level it settles at over hours, not by the first minutes, and compare it with the baseline from the same build.
systemctl status katana@xboard | grep Memorysystemctl show -p MemoryCurrent katana@xboardIf you set a hard limit with MemoryMax= in a drop-in, leave generous headroom above the level you observed. When the kernel kills katana at the limit, every connection on the instance drops, and the traffic counted since the last report is lost, because katana keeps its counters in memory. Restart=on-failure then starts it again.
File descriptors
Section titled “File descriptors”Every accepted TCP connection holds one descriptor, and every flow that reaches an outbound usually holds another. A gRPC connection can carry many streams, each with its own outbound. A direct UDP flow can hold one socket per address family. A Hysteria 2 node shares one UDP socket for all its clients, but its streams open outbound sockets like any other node.
katana does not raise its own descriptor limit, so the limit systemd gives it is the one it has. When it runs out, the node stops accepting: it logs accept error, backing off 100ms: Too many open files (os error 24) and tries again every 100 ms until descriptors come free. The built-in connection limits below are higher than LimitNOFILE=1048576, so on a busy host the descriptor limit is the one reached first. Check what a running instance has:
pid=$(systemctl show -p MainPID --value katana@xboard)sudo ls /proc/$pid/fd | wc -lgrep 'open files' /proc/$pid/limitsPer-node limits
Section titled “Per-node limits”These limits are built in and cannot be configured. They protect a node, not the host, so size LimitNOFILE= and memory for your real load rather than for these numbers.
| Limit | Value | When it is reached |
|---|---|---|
| Live connections per node (stream nodes) | 4,194,304 | A new socket is accepted and closed at once. A gRPC connection holds one place for all its streams. Connections on the node’s port and on its handoff socket count together. |
| Connections in their handshake per node (stream nodes) | 204,800 | A new socket is accepted and closed at once. Connections on the node’s port and on its handoff socket count together. |
| Time to finish the protocol handshake (stream nodes) | 10 s | The connection is closed. |
| Relay with no traffic in either direction (stream nodes) | 300 s | The connection is closed. |
| Hysteria 2 QUIC connections per node | 262,144 | A new connection is refused. |
| Hysteria 2 proxy streams and UDP sessions per node, across all connections | 4,194,304 | A new stream is reset; a new UDP session’s packets are dropped. |
The runtime logs each refusal at debug, which the default info filter hides. Connection guardrails lists the per-connection limits of Hysteria 2 as well, and the log lines.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
The unit is active (running) but a node has no listening on line |
The node did not build at start, or it is still retrying: its panel request failed, katana refused the node the panel describes (node_info failed: parse UniProxy config response: …, such as a port outside 1 to 65535), the panel returned no user list, or its bind failed. |
Read the node’s latest ERROR line. A retrying node’s line ends in ; retrying in Ns, and once you fix the cause the node comes up at its next retry; restart the instance only after a unit or capability change. A node that did not build logs node N: … once; fix its entry and save the file. |
initial start failed: inbound …: binding … failed: Permission denied (os error 13); retrying in …s |
Port below 1024 without CAP_NET_BIND_SERVICE, often after an upgrade removed a setcap capability. |
Use the unit’s AmbientCapabilities=, then restart the instance. |
initial start failed: inbound …: binding … failed: Address already in use (os error 98); retrying in …s |
Another instance or program holds the port. --test cannot detect this. |
Keep ports unique across instances. The node takes the port at its next retry after the other holder releases it. |
The unit fails at ExecStartPre with configuration error: No such file or directory (os error 2), or the same error after node N: |
The config file is missing, or a file it names (geodata, [dns] ca_file, the certificate or key of a Hysteria 2 node on Xboard or V2board) does not exist, often because of a relative path. |
Check the instance name against the file name, and use absolute paths. |
configuration error: Permission denied (os error 13) from the start check, or configuration error: node N: Permission denied (os error 13) |
The katana user cannot read the config or a file it names. |
Group katana, mode 0640. |
| IPv6 clients reach a node after an upgrade from 3.x | listen_ip = "0.0.0.0" binds [::] on a dual-stack host, which takes IPv4 and IPv6. |
Allow or block IPv6 in the firewall as you intend, or set listen_ip to a specific IPv4 address. |
version `GLIBC_2.xx' not found |
The -gnu build on a host with an older glibc. |
Use the -musl build. |
cp: cannot create regular file '/usr/local/bin/katana': Text file busy |
Copying over the running binary. | Install by rename, as in the upgrade steps. |
Sequences like [2m in the journal |
Colour codes. | Environment=NO_COLOR=1. |
journalctl -p warning shows nothing |
journald stores katana’s lines as info. |
Filter with -g 'WARN|ERROR'. |
| The service stopped and systemd did not restart it | It received SIGHUP, or was stopped on purpose. |
Remove any ExecReload= that sends SIGHUP. |
accept error, backing off 100ms: Too many open files (os error 24) |
Descriptor limit too low. | Raise LimitNOFILE=. |
initial start failed: inbound …: binding handoff:… failed: Read-only file system (os error 30), … Permission denied (os error 13) or … Operation not permitted (os error 1) |
katana cannot create the handoff directory or the socket in it, or its user is not in handoff_group. |
See Handoff sockets. |
More node-level errors, and what the panel’s answers mean, are on Troubleshooting.