feat: cleanup removal of old ssh plexer and logic

we also have added the necessary logic to auto prune ephemeral nodes because
headscale doesn't seem to automatically remove them. this change made use of a database
which is now stored in the persistent headplane directory.
This commit is contained in:
Aarnav Tale
2025-06-20 00:14:00 -04:00
parent bf1d75a27a
commit b18147fa82
24 changed files with 963 additions and 547 deletions
+26
View File
@@ -0,0 +1,26 @@
import { mkdir } from 'node:fs/promises';
import { dirname } from 'node:path';
import { drizzle } from 'drizzle-orm/better-sqlite3';
import { migrate } from 'drizzle-orm/better-sqlite3/migrator';
import log from '~/utils/log';
export async function createDbClient(path: string) {
try {
await mkdir(dirname(path), { recursive: true });
} catch (error) {
log.error(
'server',
'Failed to create directory for database at %s: %s',
path,
error instanceof Error ? error.message : String(error),
);
throw new Error(`Could not create directory for database at ${path}`);
}
const db = drizzle(path);
migrate(db, {
migrationsFolder: './drizzle',
});
return db;
}