Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): refuse startup when another server owns the state dir #4420

Closedcolonelpanic8(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/4420/headopened View on GitHub

Showing 4 changed files with 185 additions and 0 deletions (loading 1).

x
0 of 4 viewed, 4 left
1 addition and 0 deletionsapps/server/src/persistence/Layers/Sqlite.tsModified
View file
@@ -35,6 +35,7 @@
const sql = yield* SqlClient.SqlClient;
yield* sql`PRAGMA journal_mode = WAL;`;
yield* sql`PRAGMA foreign_keys = ON;`;
+ yield* sql`PRAGMA busy_timeout = 5000;`;
yield* runMigrations();
}),
);
10 additions and 0 deletionsapps/server/src/server.tsModified
View file
@@ -87,6 +87,7 @@
import { OrchestrationLayerLive } from "./orchestration/runtimeLayer.ts";
import {
clearPersistedServerRuntimeState,
+ ensureExclusiveStateDir,
makePersistedServerRuntimeState,
persistServerRuntimeState,
} from "./serverRuntimeState.ts";
@@ -374,6 +375,15 @@
Effect.gen(function* () {
const config = yield* ServerConfig.ServerConfig;
​
+ // Refuse startup (before binding or writing the discovery file) when another
+ // live T3 server already owns this state directory. Platform services are
+ // provided locally so this guard does not leak a FileSystem requirement past
+ // the "only ServerConfig" boundary below.
+ yield* ensureExclusiveStateDir({