Replace the conflated `runner` axis with two orthogonal ones: `manager`
(systemd|caddy|path|none) — who supervises/realizes a deployment — and, for
systemd only, a nested `launcher` (python|command|container|compose|node) — how
the process starts. ServiceSpec and JobSpec collapse into one manager-
discriminated DeploymentSpec union (Systemd/Caddy/Path/Remote); the services/
and jobs/ config dirs collapse into one deployments/ dir. The human "kind"
(service|job|tool|static|reference) is fully derived (kind_for), never stored —
the frontend kind is renamed static. behavior is gone.
- core: DeploymentSpec union + LaunchSpec + kind_for; legacy-aware loader
normalizes old runner shapes; CastleConfig.deployments with derived
services/jobs/tools views; registry.Deployment carries manager/launcher/kind.
- cli: service/job/tool as filtered views + a deployment group; --behavior→--kind,
create --runner→--launcher; lifecycle dispatches over config.deployments.
- castle-api: /deployments primary with /services,/jobs as views; summaries
derive kind; PUT/DELETE /config/deployments/{name} (services/jobs aliased).
- app: KindBadge, frontend→static everywhere, pick-a-kind creation wizard,
per-kind config editors.
- docs: single deployments/ layout, manager/launcher, static kind throughout.
Live migration verified byte-identical: regenerated Caddyfile and every unit
ExecStart line unchanged, so nothing restarted. Suites: core 124, cli 25,
castle-api 55; dashboard build + type-check clean.
116 lines
3.9 KiB
TypeScript
116 lines
3.9 KiB
TypeScript
import { ExternalLink, Play, RefreshCw, Server, Square, Terminal } from "lucide-react"
|
|
import { Link } from "react-router-dom"
|
|
import type { ServiceSummary, HealthStatus } from "@/types"
|
|
import { useServiceAction } from "@/services/api/hooks"
|
|
import { launcherLabel, subdomainUrl } from "@/lib/labels"
|
|
import { HealthBadge } from "./HealthBadge"
|
|
import { StackBadge } from "./StackBadge"
|
|
|
|
interface ServiceCardProps {
|
|
service: ServiceSummary
|
|
health?: HealthStatus
|
|
}
|
|
|
|
export function ServiceCard({ service, health }: ServiceCardProps) {
|
|
const hasHttp = service.port != null
|
|
const { mutate, isPending } = useServiceAction()
|
|
|
|
const doAction = (action: string) => {
|
|
mutate({ name: service.id, action })
|
|
}
|
|
|
|
const isDown = health?.status === "down"
|
|
|
|
return (
|
|
<div className="relative bg-[var(--card)] border border-[var(--border)] rounded-lg p-5 hover:border-[var(--primary)] transition-colors">
|
|
<div className="flex items-start justify-between mb-2">
|
|
<Link
|
|
to={`/services/${service.id}`}
|
|
className="text-base font-semibold hover:text-[var(--primary)] transition-colors after:absolute after:inset-0"
|
|
>
|
|
{service.id}
|
|
</Link>
|
|
{health ? (
|
|
<HealthBadge status={health.status} latency={health.latency_ms} />
|
|
) : hasHttp ? (
|
|
<HealthBadge status="unknown" />
|
|
) : null}
|
|
</div>
|
|
|
|
<div className="flex gap-1.5 mb-2">
|
|
<StackBadge stack={service.stack} />
|
|
</div>
|
|
|
|
{service.description && (
|
|
<p className="text-sm text-[var(--muted)] mb-3">{service.description}</p>
|
|
)}
|
|
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex items-center gap-3 text-xs text-[var(--muted)]">
|
|
{service.port && (
|
|
<span className="flex items-center gap-1 font-mono">
|
|
<Server size={12} />:{service.port}
|
|
</span>
|
|
)}
|
|
{service.launcher && (
|
|
<span className="flex items-center gap-1">
|
|
<Terminal size={12} />
|
|
{launcherLabel(service.launcher)}
|
|
</span>
|
|
)}
|
|
{service.subdomain && (
|
|
<a
|
|
href={subdomainUrl(service.subdomain) ?? undefined}
|
|
className="relative z-10 flex items-center gap-1 text-[var(--primary)] hover:underline"
|
|
>
|
|
<ExternalLink size={12} />
|
|
{service.subdomain}
|
|
</a>
|
|
)}
|
|
{service.port && (
|
|
<a
|
|
href={`http://localhost:${service.port}/docs`}
|
|
className="relative z-10 text-[var(--primary)] hover:underline"
|
|
>
|
|
Docs
|
|
</a>
|
|
)}
|
|
</div>
|
|
|
|
{service.managed && (
|
|
<div className="relative z-10 flex items-center gap-1">
|
|
{isDown && (
|
|
<button
|
|
onClick={() => doAction("start")}
|
|
disabled={isPending}
|
|
className="p-1 rounded hover:bg-green-800/30 text-green-400 transition-colors disabled:opacity-40"
|
|
title="Start"
|
|
>
|
|
<Play size={14} />
|
|
</button>
|
|
)}
|
|
<button
|
|
onClick={() => doAction("restart")}
|
|
disabled={isPending}
|
|
className="p-1 rounded hover:bg-blue-800/30 text-blue-400 transition-colors disabled:opacity-40"
|
|
title="Restart"
|
|
>
|
|
<RefreshCw size={14} />
|
|
</button>
|
|
{!isDown && (
|
|
<button
|
|
onClick={() => doAction("stop")}
|
|
disabled={isPending}
|
|
className="p-1 rounded hover:bg-red-800/30 text-red-400 transition-colors disabled:opacity-40"
|
|
title="Stop"
|
|
>
|
|
<Square size={14} />
|
|
</button>
|
|
)}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|