Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion engine/packages/metrics/src/registry.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use prometheus::*;

lazy_static::lazy_static! {
pub static ref REGISTRY: Registry = Registry::new_custom(None, Some(labels! { })).unwrap();
pub static ref REGISTRY: Registry = Registry::new_custom(
Some("rivet".to_string()),
Some(labels! { })).unwrap();
}
7 changes: 6 additions & 1 deletion examples/kitchen-sink/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion self-host/compose/prod-file-system/.gitattributes

This file was deleted.

76 changes: 0 additions & 76 deletions self-host/compose/prod-file-system/README.md

This file was deleted.

41 changes: 0 additions & 41 deletions self-host/compose/prod-file-system/docker-compose.yml

This file was deleted.

2 changes: 0 additions & 2 deletions self-host/compose/prod-file-system/rivet-engine/config.jsonc

This file was deleted.

75 changes: 65 additions & 10 deletions self-host/compose/template/src/docker-compose.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import * as yaml from "js-yaml";
import { CORE_NETWORK_NAME, type TemplateContext } from "./context";

const RUNNER_CONFIG_INIT_SERVICE = "runner-config-init";

export function generateDockerCompose(context: TemplateContext) {
const config = context.config;

Expand Down Expand Up @@ -172,14 +174,18 @@ export function generateDockerCompose(context: TemplateContext) {
services[postgresServiceName] = {
restart: "unless-stopped",
image: "postgres:18-alpine",
// Each engine opens a UDB connection pool (up to 64 connections) plus a
// dedicated LISTEN connection and pubsub, so a multi-engine datacenter
// needs far more than the default max_connections of 100.
command: ["postgres", "-c", "max_connections=500"],
environment: [
"POSTGRES_USER=postgres",
"POSTGRES_PASSWORD=postgres",
"POSTGRES_DB=postgres",
],
volumes: [
`./${context.getDatacenterServicePath("postgres", datacenter.name)}/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh`,
`${postgresVolumeName}:/var/lib/postgresql/data`,
`${postgresVolumeName}:/var/lib/postgresql`,
],
ports: isPrimary ? [`5432:5432`] : undefined,
healthcheck: {
Expand All @@ -194,7 +200,7 @@ export function generateDockerCompose(context: TemplateContext) {

services[shellServiceName] = {
build: {
context: "../../..",
context: "../..",
dockerfile: "docker/engine/Dockerfile",
target: "engine-full",
args: {
Expand Down Expand Up @@ -275,7 +281,7 @@ export function generateDockerCompose(context: TemplateContext) {

services[serviceName] = {
build: {
context: "../../..",
context: "../..",
dockerfile: "docker/engine/Dockerfile",
target: "engine-full",
args: {
Expand Down Expand Up @@ -335,30 +341,79 @@ export function generateDockerCompose(context: TemplateContext) {

services[serviceName] = {
build: {
context: "../../..",
dockerfile: "engine/sdks/rust/test-envoy/Dockerfile",
context: "../..",
dockerfile: "examples/kitchen-sink/Dockerfile",
// The runner copies the host-built napi binary, so the base
// image must have a glibc at least as new as the build host.
args: {
NODE_IMAGE: "node:22-trixie-slim",
},
},
platform: "linux/amd64",
restart: "unless-stopped",
environment: [
`RIVET_KITCHEN_SINK_MODE=serverful`,
`RIVET_ENDPOINT=http://${context.getServiceHost("rivet-engine", datacenter.name, 0)}:6420`,
`INTERNAL_SERVER_PORT=5050`,
`RIVET_POOL_NAME=test-envoy`,
`AUTOSTART_ENVOY=1`,
`AUTOCONFIGURE_SERVERLESS=0`
`RIVET_TOKEN=dev`,
`RIVET_NAMESPACE=default`,
`RIVET_POOL=default`,
`PORT=8080`,
],
stop_grace_period: "4s",
ports: isPrimary && i === 0 ? [`5050:5050`] : undefined,
ports: isPrimary && i === 0 ? [`5050:8080`] : undefined,
depends_on: {
[engineServiceName]: {
condition: "service_healthy",
},
[RUNNER_CONFIG_INIT_SERVICE]: {
condition: "service_completed_successfully",
},
},
networks: [dcNetworkName],
};
}
});

// Serverful runners are rejected with `no_runner_config` until a runner
// config exists for their pool, so a one-shot init container upserts a
// `normal` runner config for the `default` pool across every datacenter once
// the leader engine is healthy. The runners wait for this to finish.
const primaryDc = config.datacenters[0];
const primaryEngineHost = context.getServiceHost(
"rivet-engine",
primaryDc.name,
0,
);
const primaryEngineService = context.getServiceName(
"rivet-engine",
primaryDc.name,
0,
);
const runnerConfigBody = JSON.stringify({
datacenters: Object.fromEntries(
config.datacenters.map((dc) => [dc.name, { normal: {} }]),
),
});
const runnerConfigScript = [
`until curl -fsS -X PUT`,
`"http://${primaryEngineHost}:6420/runner-configs/default?namespace=default"`,
`-H "Authorization: Bearer dev"`,
`-H "Content-Type: application/json"`,
`-d '${runnerConfigBody}';`,
`do echo "waiting for engine to accept runner config"; sleep 2; done;`,
`echo "runner config upserted"`,
].join(" ");
services[RUNNER_CONFIG_INIT_SERVICE] = {
image: "curlimages/curl:latest",
restart: "no",
depends_on: {
[primaryEngineService]: { condition: "service_healthy" },
},
entrypoint: ["sh", "-c"],
command: [runnerConfigScript],
networks: [context.getDatacenterNetworkName(primaryDc.name)],
};

const dockerComposeConfig = {
services,
networks,
Expand Down
16 changes: 4 additions & 12 deletions self-host/compose/template/src/services/edge/rivet-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,24 @@ export function generateDatacenterRivetEngine(
datacenters,
};

// Config structure matching Rust schema in packages/common/config/src/config/mod.rs
// Config structure matching Rust schema in engine/packages/config/src/config/mod.rs.
// Values that match the engine's defaults are omitted.
const config = {
auth: {
admin_token: "dev",
},
guard: {
port: GUARD_PORT,
// https is optional and not configured for local development
},
api_peer: {
host: "0.0.0.0",
port: API_PEER_PORT,
},
topology,
postgres: {
url: `postgresql://postgres:postgres@${context.getServiceHost("postgres", datacenter.name)}:5432/rivet_engine`,
},
cache: {
driver: "in_memory",
},
clickhouse: {
http_url: `http://${clickhouseHost}:9300`, // TODO:
native_url: `http://${clickhouseHost}:9301`, // TODO:
http_url: `http://${clickhouseHost}:9300`,
native_url: `http://${clickhouseHost}:9301`,
username: "system",
password: "default",
secure: false,
},
};

Expand Down
5 changes: 3 additions & 2 deletions self-host/compose/template/src/services/edge/runner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { TemplateContext } from "../../context";

export function generateRunner(context: TemplateContext) {
// The test runner service now uses the Rust test-envoy binary.
// The docker-compose template points at the Rust Dockerfile directly.
// The runner service runs the kitchen-sink example in serverful mode,
// connecting to the engine as a long-lived runner. The docker-compose
// template builds examples/kitchen-sink/Dockerfile directly.
}
File renamed without changes.
Loading
Loading