Skip to content
Closed
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
5 changes: 3 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ features = ["now"]

[workspace.dependencies.clap]
version = "4.3"
features = ["derive"]
features = ["derive", "cargo"]

[workspace.dependencies.rivet-term]
git = "https://github.com/rivet-dev/rivet-term"
Expand Down
7 changes: 4 additions & 3 deletions engine/docker/universal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# MARK: Builder
# TODO(RVT-4168): Compile libfdb from scratch for ARM
FROM rust:1.88.0-bookworm AS builder
FROM rust:1.91.0-trixie AS builder

# Docker automatically provides TARGETARCH
ARG TARGETARCH
Expand Down Expand Up @@ -75,7 +75,7 @@ RUN \
cp target/$CARGO_BUILD_MODE/rivet-engine /app/dist/

# MARK: Engine (full, base)
FROM debian:12.9-slim AS engine-full-base
FROM debian:13.1-slim AS engine-full-base

# Docker automatically provides TARGETARCH
ARG TARGETARCH
Expand Down Expand Up @@ -108,7 +108,7 @@ ENTRYPOINT ["/usr/bin/rivet-engine"]
CMD ["start"]

# MARK: Engine (Slim)
FROM debian:12.9-slim AS engine-slim
FROM debian:13.1-slim AS engine-slim

LABEL org.opencontainers.image.source=https://github.com/rivet-gg/rivet

Expand All @@ -130,3 +130,4 @@ COPY --from=builder /app/dist/rivet-engine /usr/bin/rivet-engine

ENTRYPOINT ["/usr/bin/rivet-engine"]
CMD ["start"]

2 changes: 0 additions & 2 deletions engine/packages/api-public/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,3 @@ utoipa.workspace = true
[build-dependencies]
anyhow.workspace = true
fs_extra.workspace = true
vergen.workspace = true
vergen-gitcl.workspace = true
8 changes: 0 additions & 8 deletions engine/packages/api-public/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ use std::fs;
use std::path::Path;

fn main() -> Result<()> {
// Configure vergen to emit build metadata
vergen::Emitter::default()
.add_instructions(&vergen::BuildBuilder::all_build()?)?
.add_instructions(&vergen::CargoBuilder::all_cargo()?)?
.add_instructions(&vergen::RustcBuilder::all_rustc()?)?
.add_instructions(&vergen_gitcl::GitclBuilder::all_git()?)?
.emit()?;

let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let out_dir = env::var("OUT_DIR").unwrap();
let ui_dir = Path::new(&out_dir).join("ui");
Expand Down
17 changes: 9 additions & 8 deletions engine/packages/api-public/src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use axum::Json;
use axum::response::IntoResponse;
use rivet_api_builder::extract::Extension;
use rivet_util::build_meta;
use serde_json::json;

use crate::ctx::ApiCtx;
Expand All @@ -11,13 +12,13 @@ pub async fn get_metadata(Extension(ctx): Extension<ApiCtx>) -> impl IntoRespons
ctx.skip_auth();

Json(json!({
"runtime": "engine",
"version": env!("CARGO_PKG_VERSION"),
"git_sha": env!("VERGEN_GIT_SHA"),
"build_timestamp": env!("VERGEN_BUILD_TIMESTAMP"),
"rustc_version": env!("VERGEN_RUSTC_SEMVER"),
"rustc_host": env!("VERGEN_RUSTC_HOST_TRIPLE"),
"cargo_target": env!("VERGEN_CARGO_TARGET_TRIPLE"),
"cargo_profile": if env!("VERGEN_CARGO_DEBUG") == "true" { "debug" } else { "release" }
"runtime": build_meta::RUNTIME,
"version": build_meta::VERSION,
"git_sha": build_meta::GIT_SHA,
"build_timestamp": build_meta::BUILD_TIMESTAMP,
"rustc_version": build_meta::RUSTC_VERSION,
"rustc_host": build_meta::RUSTC_HOST,
"cargo_target": build_meta::CARGO_TARGET,
"cargo_profile": build_meta::cargo_profile()
}))
}
1 change: 1 addition & 0 deletions engine/packages/engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ hex.workspace = true
include_dir.workspace = true
indoc.workspace = true
lz4_flex.workspace = true
once_cell.workspace = true
pegboard-runner.workspace = true
pegboard-serverless.workspace = true
reqwest.workspace = true
Expand Down
17 changes: 16 additions & 1 deletion engine/packages/engine/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@ use std::{path::PathBuf, sync::Arc};

use anyhow::*;
use clap::Parser;
use once_cell::sync::Lazy;
use rivet_engine::{SubCommand, run_config};
use rivet_util::build_meta;

static LONG_VERSION: Lazy<String> = Lazy::new(|| {
format!(
"{}\nGit SHA: {}\nBuild Timestamp: {}\nRustc Version: {}\nRustc Host: {}\nCargo Target: {}\nCargo Profile: {}",
build_meta::VERSION,
build_meta::GIT_SHA,
build_meta::BUILD_TIMESTAMP,
build_meta::RUSTC_VERSION,
build_meta::RUSTC_HOST,
build_meta::CARGO_TARGET,
build_meta::cargo_profile()
)
});

#[derive(Parser)]
#[command(name = "Rivet", version, about)]
#[command(name = "Rivet", version, long_version = LONG_VERSION.as_str(), about)]
struct Cli {
#[command(subcommand)]
command: SubCommand,
Expand Down
9 changes: 6 additions & 3 deletions engine/packages/engine/tests/common/actors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,12 @@ pub async fn ping_actor_websocket_via_guard(guard_port: u16, actor_id: &str) ->
// URL encode the actor ID since colons are not allowed in WebSocket protocol names
request.headers_mut().insert(
"Sec-WebSocket-Protocol",
format!("rivet, rivet_target.actor, rivet_actor.{}", urlencoding::encode(&actor_id))
.parse()
.unwrap(),
format!(
"rivet, rivet_target.actor, rivet_actor.{}",
urlencoding::encode(&actor_id)
)
.parse()
.unwrap(),
);

// Connect to WebSocket
Expand Down
8 changes: 4 additions & 4 deletions engine/packages/pegboard-gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ use http_body_util::{BodyExt, Full};
use hyper::{Request, Response, StatusCode};
use rivet_error::*;
use rivet_guard_core::{
WebSocketHandle,
custom_serve::{CustomServeTrait, HibernationResult},
errors::{ServiceUnavailable, WebSocketServiceUnavailable},
proxy_service::{is_ws_hibernate, ResponseBody},
proxy_service::{ResponseBody, is_ws_hibernate},
request_context::RequestContext,
websocket_handle::WebSocketReceiver,
WebSocketHandle,
};
use rivet_runner_protocol as protocol;
use rivet_util::serde::HashableMap;
use std::{sync::Arc, time::Duration};
use tokio::sync::{watch, Mutex};
use tokio::sync::{Mutex, watch};
use tokio_tungstenite::tungstenite::{
protocol::frame::{coding::CloseCode, CloseFrame},
Message,
protocol::frame::{CloseFrame, coding::CloseCode},
};

use crate::shared_state::{InFlightRequestHandle, SharedState};
Expand Down
6 changes: 3 additions & 3 deletions engine/packages/pegboard-gateway/src/shared_state.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use anyhow::Result;
use gas::prelude::*;
use rivet_guard_core::errors::WebSocketServiceTimeout;
use rivet_runner_protocol::{self as protocol, versioned, PROTOCOL_VERSION};
use scc::{hash_map::Entry, HashMap};
use rivet_runner_protocol::{self as protocol, PROTOCOL_VERSION, versioned};
use scc::{HashMap, hash_map::Entry};
use std::{
ops::Deref,
sync::Arc,
Expand All @@ -12,7 +12,7 @@ use tokio::sync::{mpsc, watch};
use universalpubsub::{NextOutput, PubSub, PublishOpts, Subscriber};
use vbare::OwnedVersionedData;

use crate::{metrics, WebsocketPendingLimitReached};
use crate::{WebsocketPendingLimitReached, metrics};

const GC_INTERVAL: Duration = Duration::from_secs(15);
const TUNNEL_PING_TIMEOUT: i64 = util::duration::seconds(30);
Expand Down
5 changes: 5 additions & 0 deletions engine/packages/util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ tracing.workspace = true
url.workspace = true
uuid.workspace = true
utoipa.workspace = true

[build-dependencies]
anyhow.workspace = true
vergen.workspace = true
vergen-gitcl.workspace = true
13 changes: 13 additions & 0 deletions engine/packages/util/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use anyhow::Result;

fn main() -> Result<()> {
// Configure vergen to emit build metadata
vergen::Emitter::default()
.add_instructions(&vergen::BuildBuilder::all_build()?)?
.add_instructions(&vergen::CargoBuilder::all_cargo()?)?
.add_instructions(&vergen::RustcBuilder::all_rustc()?)?
.add_instructions(&vergen_gitcl::GitclBuilder::all_git()?)?
.emit()?;

Ok(())
}
33 changes: 33 additions & 0 deletions engine/packages/util/src/build_meta.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/// Runtime identifier for the engine
pub const RUNTIME: &str = "engine";

/// Package version from Cargo.toml
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

/// Git commit SHA
pub const GIT_SHA: &str = env!("VERGEN_GIT_SHA");

/// Build timestamp
pub const BUILD_TIMESTAMP: &str = env!("VERGEN_BUILD_TIMESTAMP");

/// Rustc version used to compile
pub const RUSTC_VERSION: &str = env!("VERGEN_RUSTC_SEMVER");

/// Rustc host triple
pub const RUSTC_HOST: &str = env!("VERGEN_RUSTC_HOST_TRIPLE");

/// Cargo target triple
pub const CARGO_TARGET: &str = env!("VERGEN_CARGO_TARGET_TRIPLE");

/// Cargo debug flag as string
const CARGO_DEBUG: &str = env!("VERGEN_CARGO_DEBUG");

/// Cargo profile (debug or release)
/// Returns "debug" if VERGEN_CARGO_DEBUG is "true", otherwise "release"
pub fn cargo_profile() -> &'static str {
if CARGO_DEBUG == "true" {
"debug"
} else {
"release"
}
}
1 change: 1 addition & 0 deletions engine/packages/util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pub use rivet_util_id as id;

pub mod backoff;
pub mod billing;
pub mod build_meta;
pub mod check;
pub mod duration;
pub mod faker;
Expand Down
9 changes: 5 additions & 4 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ pre-commit:
run: cargo fmt --all
tags: formatting
stage_fixed: true
biome-fmt:
run: pnpm fmt
tags: formatting
stage_fixed: true
# TODO: Bring this back after big dumb errors are fixed
# biome-fmt:
# run: pnpm fmt
# tags: formatting
# stage_fixed: true

Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class FileSystemGlobalState {

constructor(persist: boolean = true, customPath?: string) {
this.#persist = persist;
this.#storagePath = persist ? getStoragePath(customPath) : "/tmp";
this.#storagePath = persist ? (customPath ?? getStoragePath()) : "/tmp";
const path = getNodePath();
this.#stateDir = path.join(this.#storagePath, "state");
this.#dbsDir = path.join(this.#storagePath, "databases");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ function createHashForPath(dirPath: string): string {
/**
* Get the storage path for the current working directory or a specified path
*/
export function getStoragePath(customPath?: string): string {
export function getStoragePath(): string {
const dataPath = getDataPath("rivetkit");
const pathToHash = customPath || process.cwd();
const dirHash = createHashForPath(pathToHash);
const dirHash = createHashForPath(process.cwd());
const path = getNodePath();
return path.join(dataPath, dirHash);
}
Expand Down
8 changes: 4 additions & 4 deletions rivetkit-typescript/packages/rivetkit/src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export {
export { InlineWebSocketAdapter } from "@/common/inline-websocket-adapter";
export { noopNext } from "@/common/utils";
export { createEngineDriver } from "@/drivers/engine/mod";
// export {
// createFileSystemDriver,
// createMemoryDriver,
// } from "@/drivers/file-system/mod";
export {
createFileSystemDriver,
createMemoryDriver,
} from "@/drivers/file-system/mod";
export type { ActorQuery } from "@/manager/protocol/query";
export * from "@/registry/mod";
export { toUint8Array } from "@/utils";
Loading