Deployments: serve a model with a runtime container
- deployments + deployment_logs tables; desired/actual state reconciled by the worker (create/start/stop/remove via the socket proxy, /health wait, log follower, stats, memory guard, adopt/remove containers on restart). - Pure command builder for llama-server and vllm serve (mmproj, MTP draft, KV cache types, dtype, KV cache size) with tests; file candidates per engine with tests. - New main menu entry Deployments: list, new/edit form (runtime -> model and files -> launch options, live command preview), detail page with stats, log, endpoint and a streaming chat smoke test. Not yet tested end-to-end against real containers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4f7ae1fc8c
commit
8b74fa69db
32 files changed
+3824
-3
No files matched your search
@@ -12,6 +12,7 @@ import { coreEnv } from "@/lib/env";
|
||||
import { checkHub, modelsDueForHubCheck } from "@/lib/hub/availability";
|
||||
import { backfillMetadata } from "@/lib/hub/refresh";
|
||||
import { DeleteRunner } from "./delete";
|
||||
import { adoptContainers, flushDeploymentLogs, LOG_FLUSH_INTERVAL_MS, reconcileDeployments, stopFollowingLogs } from "./deployments";
|
||||
import { DownloadRunner } from "./download";
|
||||
import { log } from "./log";
|
||||
import type { Runner } from "./runner";
|
||||
@@ -32,6 +33,7 @@ const FOLDER_SCAN_MS = 2 * 60_000;
|
||||
const DOCKER_INFO_MS = 5 * 60_000;
|
||||
const IMAGE_SYNC_MS = 60_000;
|
||||
const PULL_CHECK_MS = 3_000;
|
||||
const DEPLOYMENT_TICK_MS = 2_000;
|
||||
/** Touched on every heartbeat; the Docker healthcheck checks its age. */
|
||||
const HEALTH_FILE = join(tmpdir(), "kaname-worker-alive");
|
||||
|
||||
@@ -343,6 +345,9 @@ async function shutdown(reason: string, code = 0) {
|
||||
stopping = true;
|
||||
log.info(`shutting down (${reason})`);
|
||||
timers.forEach(clearInterval);
|
||||
// Deployment containers keep running; the next worker re-attaches to them.
|
||||
stopFollowingLogs();
|
||||
await flushDeploymentLogs().catch(() => {});
|
||||
if (runners.size > 0) {
|
||||
for (const r of runners.values()) r.interrupt();
|
||||
const deadline = Date.now() + SHUTDOWN_GRACE_MS;
|
||||
@@ -394,6 +399,11 @@ async function main() {
|
||||
timers.push(setInterval(() => void dockerInfo(), DOCKER_INFO_MS));
|
||||
timers.push(setInterval(() => void imageSync(), IMAGE_SYNC_MS));
|
||||
timers.push(setInterval(() => void handlePullRequests().catch((err) => log.error("pull failed", err)), PULL_CHECK_MS));
|
||||
|
||||
// Deployments: re-attach to running containers, then keep them in line with the desired state.
|
||||
await adoptContainers();
|
||||
timers.push(setInterval(() => void reconcileDeployments().catch((err) => log.error("deployments failed", err)), DEPLOYMENT_TICK_MS));
|
||||
timers.push(setInterval(() => void flushDeploymentLogs().catch((err) => log.error("deployment logs failed", err)), LOG_FLUSH_INTERVAL_MS));
|
||||
void scanFolders();
|
||||
void tick();
|
||||
setTimeout(() => void checkHubDue(), 15_000);
|
||||
|
||||
Reference in new issue
Block a user