Linux
Linux is a primary native deployment target for Khora services.
x86_64-unknown-linux-gnu and aarch64-unknown-linux-gnu are two of the
triples the release workflow builds, packages, and then uses to compile and run
a program before publishing — see Supported targets for the whole
list and for what is deliberately not on it.
Install the toolchain on the build machine
Section titled “Install the toolchain on the build machine”curl -fsSL https://raw.githubusercontent.com/codyspate/khoralang/main/install.sh | shThat downloads the release for this platform, checks it against the published
.sha256, unpacks it into ~/.khora, and appends a PATH line to whichever of
~/.profile, ~/.bashrc and ~/.zshrc already exist. Nothing is compiled,
nothing needs root, and rm -rf ~/.khora undoes it.
For a build machine, pin the version and leave the shell profiles alone.
The 0.4.0 example works after the stable release is published; for a published
candidate, substitute its full version (0.4.0-rc.2) in both this command and
your project’s pin:
curl -fsSL https://raw.githubusercontent.com/codyspate/khoralang/main/install.sh \ | sh -s -- --version 0.4.0 --to /opt/khora --no-modify-pathexport PATH="/opt/khora/bin:$PATH"sh -s -- is how arguments reach a script that is being piped. --pre adds
release candidates to what a plain run would take; a plain run never reaches
one, because candidates are published as GitHub pre-releases.
One thing is not in the download and cannot be: a linker. A Khora program
is a native object that has to be linked against this platform’s C runtime, and
the driver that knows where those live belongs to the platform. Install
clang or gcc from the package manager. The installer checks before
downloading anything and warns rather than refusing, so a missing linker shows
up at khora build if you skip it.
khora install # only if the project has dependencies; needs gitkhora check .khora test .khora build . --releaseThe executable is build/<package>. Run it:
./build/myserviceNothing else is copied to the target host. The binary carries the Khora runtime
and does not need std/, the compiler, or a language VM beside it. What it does
need is the system C library it was linked against — a default build on a
glibc distribution is dynamically linked against glibc, and one on Alpine is
static — and ca-certificates, if the service opens outbound TLS
connections, because a TlsClient verifies against the machine’s own trust
store. To need no C library at all, build a static executable with
--target x86_64-unknown-linux-musl (or aarch64-unknown-linux-musl); see
Static executables.
Strip the debug information before you ship it. A release build emits none
for your Khora code, but the runtime linked into every program carries its own
— most of a release binary’s size. strip --strip-debug removes that and
nothing else, so a program behaves the same and a trap’s backtrace still names
its functions:
strip --strip-debug build/myserviceA bare strip saves a little more by removing the symbol table too, and then
every backtrace frame reads <unknown>. Keep an unstripped copy if you want a
debugger to see the runtime’s frames.
Build on the architecture you deploy to, or build static. A dynamically
linked program for another architecture is not supported: KHORA_TARGET makes
the compiler emit for another triple, but the link needs that triple’s glibc.
A static musl executable is the exception — every Linux toolchain builds one
for either architecture, given clang and ld.lld.
Running it under systemd
Section titled “Running it under systemd”Khora contributes nothing special here — the unit is the ordinary one for a native binary, which is the point:
[Unit]Description=myserviceAfter=network-online.targetWants=network-online.target
[Service]ExecStart=/usr/local/bin/myserviceWorkingDirectory=/var/lib/myserviceUser=myserviceGroup=myserviceRestart=on-failure
[Install]WantedBy=multi-user.targetsudo install -m 0755 build/myservice /usr/local/bin/myservicesudo systemctl daemon-reloadsudo systemctl enable --now myservicejournalctl -u myservice -fWorkingDirectory is worth setting deliberately. A relative path a program
opens is relative to where the process was started, not to where its
khora.toml was, and an [permissions.fs] grant written as ./data/** is
resolved against the manifest — so a service started from / and a service
started from its own directory disagree about which files exist.
The port is part of the manifest under default = "deny". A service that
reads its port from the environment can only bind the ones [permissions] listen grants, so the port in the unit file and the grant have to agree:
[permissions]default = "deny"listen = ["8080"] # or a range the operator may choose from: "8000-8099"network = ["127.0.0.1:5432"]env = ["PORT", "DATABASE_URL"]A port the grant does not cover is refused before anything is bound, with
HttpError::Denied naming the address, rather than served. network is what
the service dials; it grants no port to listen on.
std::log writes one JSON object per line to standard error, which is where
journalctl and every container log collector already look; there is no log
file to rotate unless you make one.
Shutdown
Section titled “Shutdown”A SIGTERM from systemctl stop becomes a cancellation at the root of the
program. Nursery cancellation runs, scoped finalizers run, in-flight
requests unwind, and the process exits 130. systemd already reports that as a
clean stop, and TimeoutStopSec stays the deadline: the runtime has no grace
period of its own, so the number in your unit file is the only one. A second
SIGTERM — or TimeoutStopSec expiring into SIGKILL — ends it at once.
Two shapes still end the process without a clean stop, and a service that must survive either should be written so that being killed at an arbitrary instant is survivable — commit before acknowledging, and let the next start recover:
- a
mainthat reaches no cancellation point at all — no loop, no blocking call, no call to a function that has one. There is nowhere in it to stop, so the runtime uses the default disposition and the process dies at wait-status 143 with no finalizers rather than hanging. Anymainthat loops, serves or waits has a cancellation point, whatever itsraisesrow; - a fiber inside a blocking
connect_to, which reaches no cancellation point untilconnect(2)gives up.
Cancellation-safe resources is the pattern, for a deploy as much as for a nursery.
Khora 0.4.0built fromee766ae43388on 2026-11-26 22:56ZVersioningSecurityContributingReleasesSource