Skip to content

Service

Source: src/Hetzner/Service.ts

An Effect program hosted on a Hetzner Cloud Server as a systemd unit.

N Services can share one Server. Each Service is bundled with rolldown, copied over SSH, and restarted as its own unit. Bind Hetzner.MountVolume inside the impl to attach a Volume and mount it at a path — the same (volume, server, path) from two Services is one attach and one mount.

const server = yield* Hetzner.Server("box", {
serverType: "cpx12",
image: "ubuntu-24.04",
location: "nbg1",
});
export default class Api extends Hetzner.Service<Api>()(
"Api",
{ server, main: import.meta.url, port: 3000 },
Effect.gen(function* () {
return {
fetch: Effect.succeed(HttpServerResponse.json({ ok: true })),
};
}),
) {}
const mount = yield* Hetzner.MountVolume(volume, { path: "/data" });
// write/read files under mount.path inside the hosted process