INNER CODE UNIT · TypeScript
cmdDown
PerryTS/perry · example-code/forgejo-deployment/main.ts:404
async function cmdDown(c: StackConfig): Promise<void> {
await preflightOrExit(c.httpPort, c.sshPort);
const flag = envOr('FORGEJO_DESTROY_ON_EXIT', '');
const destroy = flag === '1' || flag === 'true' || flag === 'yes';
console.log(
`📥 Tearing down Forgejo stack ` +
(destroy ? '(volumes WILL be removed)' : '(volumes preserved)') +
'...'
);
// Re-up against the same spec to obtain a stack handle for the
// already-running deployment. Idempotent: services already running
// are detected via `inspect` and skipped (no restart, no rebuild).
// The handle returned references the same engine state — `down()`
// then operates on the live containers / networks / volumes.
const stack = await up(buildSpec(c) as never);