import { notFound } from "next/navigation"; import { Plus, RefreshCw, Server, Trash2 } from "lucide-react"; import { HOST_STATUS_RU, isSuperadmin, listHosts, type RunnerHostView } from "@peppa/core"; import { ensureSshKey, runnerImage } from "@peppa/runner"; import { Hidden } from "@/components/cards"; import { ago, Disclosure, Empty, Flash, PageHeader, Section } from "@/components/common"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; import { Input, Label } from "@/components/ui/input"; import { Workspace } from "@/components/Workspace"; import { requireUser } from "@/lib/auth"; import { db } from "@/lib/db"; import { addHostAction, checkHostAction, deleteHostAction, toggleHostAction, updateHostAction } from "./actions"; export const metadata = { title: "Хосты — Пеппа" }; function StatusOf({ h }: { h: RunnerHostView }) { if (h.disabledAt) return отключён; return {HOST_STATUS_RU[h.status]}; } function HostFields({ h }: { h?: RunnerHostView }) { return (
); } function HostCard({ h }: { h: RunnerHostView }) { const i = h.info ?? {}; return (
{h.name} {h.sshTarget}{h.sshPort !== 22 ? `:${h.sshPort}` : ""} раннеров: {h.runners}
{i.load != null && загрузка {i.load}{i.cpus ? ` / ${i.cpus} CPU` : ""}} {i.docker && docker {i.docker}} {i.tmux && {i.tmux}} {i.os && {i.os}} образ раннера: {i.image ? {i.image} : "не загружен"} проверен {ago(h.lastSeenAt)}
{h.lastError &&

{h.lastError}

}
); } export default async function Hosts({ searchParams }: { searchParams: Promise<{ error?: string }> }) { const user = await requireUser(); if (!(await isSuperadmin(db, user))) notFound(); const { error } = await searchParams; const [hosts, pub] = await Promise.all([listHosts(db), ensureSshKey().catch((e: Error) => `(ключ не создан: ${e.message})`)]); return (
Хосты}> Серверы, на которых работают раннеры. Пеппа заходит на хост по SSH своим ключом и запускает там tmux с агентом в контейнере образа раннера; агент ходит в Пеппу только через релей. Демона на хосте нет — нужны sshd, tmux и docker. Проект выбирает хосты в «⋯ Настройки проекта → Раннеры». Раздел видят только суперадмины.
{hosts.length === 0 ? Хостов нет — раннеры работают на Mac Пеппы. : hosts.map((h) => )} Подключить хост}>
  1. Добавьте ключ Пеппы в ~/.ssh/authorized_keys пользователя на хосте:
    {pub}
  2. Установите tmux и docker; пользователь должен иметь доступ к docker.
  3. Загрузите образ раннера {runnerImage()}: scripts/runner-image.sh --push <имя хоста> (или peppa host push-image <имя>).
  4. Адрес Пеппы для хоста должен открываться с хоста (по умолчанию — адрес веба); через него идут хуки, MCP и git агента.
); }