feat(gpu-server): complete GPU server setup with AI services, monitoring, and public access

- Set up 5 AI services on Windows GPU server (RTX 3090):
  - mana-llm (Port 3025): OpenAI-compatible LLM gateway via Ollama
  - mana-stt (Port 3020): WhisperX with word timestamps + speaker diarization
  - mana-tts (Port 3022): Kokoro (EN) + Edge TTS (DE) + Piper (local DE)
  - mana-image-gen (Port 3023): FLUX.2 klein 4B image generation
  - Ollama (Port 11434): gemma3:4b/12b, qwen2.5-coder:14b, nomic-embed-text

- Add @manacore/shared-gpu TypeScript client package with SttClient, TtsClient, ImageClient
- Add CUDA-compatible whisper_service using faster-whisper for Windows
- Configure public access via Cloudflare Tunnel (gpu-llm/stt/tts/img.mana.how)
- Add Loki log aggregator (Docker on Mac Mini) + log shipper on GPU server
- Add GPU scrape targets to Prometheus/VictoriaMetrics config
- Add Grafana Loki datasource for GPU service logs
- Add health check with auto-restart, log rotation, and log shipping
- Document complete setup: Always-On config, troubleshooting, architecture

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-03-27 21:35:30 +01:00
parent 7754cf6e00
commit 16e0d99c5a
13 changed files with 1245 additions and 7 deletions

View file

@ -0,0 +1,72 @@
import type {
GenerateImageOptions,
GenerateImageResult,
ImageGenHealthResponse,
GpuServiceConfig,
} from './types';
import { resolveServiceUrl } from './resolve-url';
export class ImageClient {
private baseUrl: string;
private timeout: number;
constructor(config: GpuServiceConfig) {
this.baseUrl = resolveServiceUrl(config, 'image');
this.timeout = config.timeout ?? 120_000;
}
/** Generate an image from a text prompt. */
async generate(options: GenerateImageOptions): Promise<GenerateImageResult> {
const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), this.timeout);
try {
const response = await fetch(`${this.baseUrl}/generate`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
prompt: options.prompt,
width: options.width ?? 1024,
height: options.height ?? 1024,
steps: options.steps ?? 4,
seed: options.seed,
output_format: options.outputFormat ?? 'png',
}),
signal: controller.signal,
});
if (!response.ok) {
const error = await response.json().catch(() => ({ detail: response.statusText }));
throw new Error(
`Image generation error ${response.status}: ${(error as { detail: string }).detail}`
);
}
return (await response.json()) as GenerateImageResult;
} finally {
clearTimeout(timer);
}
}
/** Get the full URL for a generated image. */
imageUrl(relativePath: string): string {
return `${this.baseUrl}${relativePath}`;
}
/** Download a generated image as ArrayBuffer. */
async downloadImage(relativePath: string): Promise<ArrayBuffer> {
const response = await fetch(this.imageUrl(relativePath), {
signal: AbortSignal.timeout(30_000),
});
if (!response.ok) throw new Error(`Failed to download image: ${response.status}`);
return response.arrayBuffer();
}
/** Check if the image generation service is healthy. */
async health(): Promise<ImageGenHealthResponse> {
const response = await fetch(`${this.baseUrl}/health`, {
signal: AbortSignal.timeout(5000),
});
return (await response.json()) as ImageGenHealthResponse;
}
}