Manager-first deployment model: split runner, merge service/job, frontend→static
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.
This commit is contained in:
@@ -5,27 +5,26 @@ import type { ProgramDetail } from "@/types"
|
||||
import { useServices, useJobs } from "@/services/api/hooks"
|
||||
import { CreateDeploymentForm, type CreatePrefill } from "./CreateDeploymentForm"
|
||||
|
||||
/** The services and jobs that deploy a program. A program → 0-N services and
|
||||
* 0-N jobs; these are convenience links, not ownership (a deployment can run
|
||||
* anything, program-backed or not). The Create buttons just prefill the
|
||||
* standalone create form with sensible values. */
|
||||
/** The services and jobs that deploy a program. A program → 0-N deployments;
|
||||
* these are convenience links, not ownership (a deployment can run anything,
|
||||
* program-backed or not). The Create button prefills the kind-aware wizard. */
|
||||
export function DeploymentsSection({ program }: { program: ProgramDetail }) {
|
||||
const { services, jobs, behavior } = program
|
||||
const { services, jobs, kind } = program
|
||||
const none = services.length === 0 && jobs.length === 0
|
||||
const [creating, setCreating] = useState<"service" | "job" | null>(null)
|
||||
const [creating, setCreating] = useState(false)
|
||||
|
||||
const { data: allServices } = useServices()
|
||||
const { data: allJobs } = useJobs()
|
||||
const existing =
|
||||
creating === "service"
|
||||
? (allServices ?? []).map((s) => s.id)
|
||||
: (allJobs ?? []).map((j) => j.id)
|
||||
const existing = [
|
||||
...(allServices ?? []).map((s) => s.id),
|
||||
...(allJobs ?? []).map((j) => j.id),
|
||||
]
|
||||
|
||||
const prefill: CreatePrefill = {
|
||||
name: program.id,
|
||||
program: program.id,
|
||||
runTarget: program.id,
|
||||
runner: program.stack?.startsWith("python") || !program.stack ? "python" : "command",
|
||||
launcher: program.stack?.startsWith("python") || !program.stack ? "python" : "command",
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -34,20 +33,12 @@ export function DeploymentsSection({ program }: { program: ProgramDetail }) {
|
||||
<h2 className="text-sm font-semibold text-[var(--muted)] uppercase tracking-wider">
|
||||
Deployments
|
||||
</h2>
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
onClick={() => setCreating(creating === "service" ? null : "service")}
|
||||
className="flex items-center gap-1 text-xs text-[var(--primary)] hover:underline"
|
||||
>
|
||||
<Plus size={12} /> Create service
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setCreating(creating === "job" ? null : "job")}
|
||||
className="flex items-center gap-1 text-xs text-[var(--primary)] hover:underline"
|
||||
>
|
||||
<Plus size={12} /> Create job
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => setCreating((c) => !c)}
|
||||
className="flex items-center gap-1 text-xs text-[var(--primary)] hover:underline"
|
||||
>
|
||||
<Plus size={12} /> Add deployment
|
||||
</button>
|
||||
</div>
|
||||
<p className="text-xs text-[var(--muted)] mb-4">
|
||||
Services and jobs that run this program.
|
||||
@@ -55,19 +46,18 @@ export function DeploymentsSection({ program }: { program: ProgramDetail }) {
|
||||
|
||||
{creating && (
|
||||
<CreateDeploymentForm
|
||||
kind={creating}
|
||||
prefill={prefill}
|
||||
existingNames={existing}
|
||||
onCancel={() => setCreating(null)}
|
||||
onCancel={() => setCreating(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{none && !creating ? (
|
||||
<p className="text-sm text-[var(--muted)]">
|
||||
{behavior === "daemon"
|
||||
? "No service yet — this daemon isn't deployed."
|
||||
: behavior === "tool"
|
||||
? "Not scheduled — add a job to run it on a timer."
|
||||
{kind === "service"
|
||||
? "No service yet — this program isn't deployed."
|
||||
: kind === "tool"
|
||||
? "Installed on PATH. Add a job to also run it on a timer."
|
||||
: "None."}
|
||||
</p>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user