mirror of
https://github.com/stablyai/orca.git
synced 2026-10-23 16:03:49 +00:00
chore: preserve current-main orcad formatting
This commit is contained in:
@@ -132,16 +132,12 @@ function compileNodePty(dir) {
|
||||
return built
|
||||
}
|
||||
console.log('[orcad-prebuilds] compiling node-pty from patched source ...')
|
||||
const result = spawnSync(
|
||||
process.platform === 'win32' ? 'npx.cmd' : 'npx',
|
||||
['node-gyp', 'rebuild'],
|
||||
{
|
||||
cwd: dir,
|
||||
stdio: 'inherit',
|
||||
env: process.env,
|
||||
windowsHide: true
|
||||
}
|
||||
)
|
||||
const result = spawnSync(process.platform === 'win32' ? 'npx.cmd' : 'npx', ['node-gyp', 'rebuild'], {
|
||||
cwd: dir,
|
||||
stdio: 'inherit',
|
||||
env: process.env,
|
||||
windowsHide: true
|
||||
})
|
||||
if (result.status !== 0) {
|
||||
throw new Error(`[orcad-prebuilds] node-gyp rebuild failed (status ${result.status})`)
|
||||
}
|
||||
|
||||
@@ -11,8 +11,7 @@ import {
|
||||
slotName
|
||||
} from './build-orcad-prebuilds.mjs'
|
||||
|
||||
const PATCHED_BINDING_GYP =
|
||||
"'ldflags': ['-Wl,--no-as-needed,-l:libutil.so.1,-l:libpthread.so.0,--as-needed']"
|
||||
const PATCHED_BINDING_GYP = "'ldflags': ['-Wl,--no-as-needed,-l:libutil.so.1,-l:libpthread.so.0,--as-needed']"
|
||||
const PATCHED_PTY_CC = '__asm__(".symver openpty,openpty@" ORCA_GLIBC_COMPAT_VERSION);'
|
||||
|
||||
const dirs = []
|
||||
@@ -108,9 +107,8 @@ describe('mergeManifest', () => {
|
||||
|
||||
it('does not duplicate a slot rebuilt twice', () => {
|
||||
const once = mergeManifest(null, { slot: 'darwin-arm64', version: '1.1.0', nodeAbi: '127' })
|
||||
expect(
|
||||
mergeManifest(once, { slot: 'darwin-arm64', version: '1.1.0', nodeAbi: '127' }).slots
|
||||
).toEqual(['darwin-arm64'])
|
||||
expect(mergeManifest(once, { slot: 'darwin-arm64', version: '1.1.0', nodeAbi: '127' }).slots)
|
||||
.toEqual(['darwin-arm64'])
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -117,7 +117,11 @@ export function parseUnmetGlibcVersion(loaderError: string): string | null {
|
||||
}
|
||||
|
||||
/** `NODE_MODULE_VERSION 115 ... requires NODE_MODULE_VERSION 127` -> { built: '115', host: '127' }. */
|
||||
export function parseNodeAbiMismatch(loaderError: string): { built: string; host: string } | null {
|
||||
const match = loaderError.match(/NODE_MODULE_VERSION\s+(\d+)\D+NODE_MODULE_VERSION\s+(\d+)/)
|
||||
export function parseNodeAbiMismatch(
|
||||
loaderError: string
|
||||
): { built: string; host: string } | null {
|
||||
const match = loaderError.match(
|
||||
/NODE_MODULE_VERSION\s+(\d+)\D+NODE_MODULE_VERSION\s+(\d+)/
|
||||
)
|
||||
return match ? { built: match[1], host: match[2] } : null
|
||||
}
|
||||
|
||||
@@ -27,12 +27,7 @@ export type PrebuiltSlotManifest = {
|
||||
|
||||
export type PrebuiltSlotOutcome =
|
||||
| { installed: true; slot: string; spawnHelper: boolean }
|
||||
| {
|
||||
installed: false
|
||||
slot: string
|
||||
why: 'no-slot' | 'no-prebuilds-dir' | 'abi-mismatch'
|
||||
detail?: string
|
||||
}
|
||||
| { installed: false; slot: string; why: 'no-slot' | 'no-prebuilds-dir' | 'abi-mismatch'; detail?: string }
|
||||
|
||||
/**
|
||||
* Where a deployment's prebuilds live: beside the bundle that is running. `argv[1]` is
|
||||
@@ -60,9 +55,7 @@ export function readPrebuiltSlotManifest(prebuildsDir: string): PrebuiltSlotMani
|
||||
module: typeof manifest.module === 'string' ? manifest.module : 'node-pty',
|
||||
version: manifest.version,
|
||||
nodeAbi: manifest.nodeAbi,
|
||||
slots: Array.isArray(manifest.slots)
|
||||
? manifest.slots.filter((s) => typeof s === 'string')
|
||||
: []
|
||||
slots: Array.isArray(manifest.slots) ? manifest.slots.filter((s) => typeof s === 'string') : []
|
||||
}
|
||||
} catch {
|
||||
return null
|
||||
|
||||
@@ -163,3 +163,4 @@ export function formatMissingToolchainError(
|
||||
]
|
||||
return lines.join('\n')
|
||||
}
|
||||
|
||||
|
||||
@@ -169,5 +169,7 @@ export function orcadGcPinnedDirNames(
|
||||
const versions = [record.active, record.previous, daemonEntryVersion ?? null].filter(
|
||||
(v): v is string => typeof v === 'string' && v.length > 0
|
||||
)
|
||||
return [...new Set(versions)].map((version) => remoteInstallDirName(ORCAD_INSTALL_MODEL, version))
|
||||
return [...new Set(versions)].map((version) =>
|
||||
remoteInstallDirName(ORCAD_INSTALL_MODEL, version)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -209,9 +209,7 @@ describe('deployOrcad', () => {
|
||||
const result = await deployOrcad(options())
|
||||
expect(result).toMatchObject({ code: 'orcad_activation_daemon_degraded' })
|
||||
expect(
|
||||
vi
|
||||
.mocked(writeRelayFile)
|
||||
.mock.calls.some((call) => String(call[2]).endsWith('orcad-active.json'))
|
||||
vi.mocked(writeRelayFile).mock.calls.some((call) => String(call[2]).endsWith('orcad-active.json'))
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
|
||||
@@ -32,7 +32,10 @@ import {
|
||||
type OrcadActivationRecord,
|
||||
type OrcadStateSnapshot
|
||||
} from './orcad-activation-record'
|
||||
import { orcadActivationPath, readOrcadActivationRecord } from './orcad-activation-record-store'
|
||||
import {
|
||||
orcadActivationPath,
|
||||
readOrcadActivationRecord
|
||||
} from './orcad-activation-record-store'
|
||||
import { evaluateOrcadActivation, type OrcadActivationVerdict } from './orcad-activation-gate'
|
||||
import { planOrcadUpdate, type OrcadTerminalCensus } from './orcad-update-plan'
|
||||
import {
|
||||
@@ -108,11 +111,9 @@ async function installOrcadBundle(
|
||||
fullVersion: string,
|
||||
remoteDir: string
|
||||
): Promise<void> {
|
||||
if (
|
||||
await isRemoteInstallComplete(options.conn, ORCAD_INSTALL_MODEL, remoteDir, options.host, {
|
||||
signal: options.signal
|
||||
})
|
||||
) {
|
||||
if (await isRemoteInstallComplete(options.conn, ORCAD_INSTALL_MODEL, remoteDir, options.host, {
|
||||
signal: options.signal
|
||||
})) {
|
||||
return
|
||||
}
|
||||
await acquireInstallLock(options.conn, remoteDir, options.host, { signal: options.signal })
|
||||
@@ -150,12 +151,7 @@ async function captureSnapshot(
|
||||
takenAt: Date
|
||||
): Promise<OrcadStateSnapshot | null> {
|
||||
const dirName = orcadSnapshotDirName(fullVersion, takenAt.getTime())
|
||||
const snapshotDir = joinRemotePath(
|
||||
options.host,
|
||||
baseDir(options),
|
||||
ORCAD_STATE_SNAPSHOT_DIR,
|
||||
dirName
|
||||
)
|
||||
const snapshotDir = joinRemotePath(options.host, baseDir(options), ORCAD_STATE_SNAPSHOT_DIR, dirName)
|
||||
const capture = parseOrcadSnapshotCapture(
|
||||
await exec(
|
||||
options,
|
||||
@@ -291,12 +287,9 @@ export async function deployOrcad(options: OrcadDeployOptions): Promise<OrcadDep
|
||||
record.active
|
||||
)
|
||||
const stopped = parseOrcadStopOutcome(
|
||||
await exec(
|
||||
options,
|
||||
stopOrcadCommand(options.host, outgoingDir, {
|
||||
waitSeconds: STOP_WAIT_SECONDS
|
||||
})
|
||||
)
|
||||
await exec(options, stopOrcadCommand(options.host, outgoingDir, {
|
||||
waitSeconds: STOP_WAIT_SECONDS
|
||||
}))
|
||||
)
|
||||
if (!orcadStopFreedTheHost(stopped)) {
|
||||
return {
|
||||
|
||||
@@ -78,9 +78,7 @@ describe('orcad GC', () => {
|
||||
currentDirAbsPath: '/home/u/.orca-remote/orcad-0.2.0+bb',
|
||||
record: emptyOrcadActivationRecord()
|
||||
})
|
||||
const listCommand = mockExec.mock.calls
|
||||
.map((call) => String(call[1]))
|
||||
.find((c) => c.includes('find'))
|
||||
const listCommand = mockExec.mock.calls.map((call) => String(call[1])).find((c) => c.includes('find'))
|
||||
expect(listCommand).toContain("-name 'orcad-*'")
|
||||
expect(listCommand).not.toContain("-name 'relay-*'")
|
||||
})
|
||||
|
||||
@@ -25,7 +25,10 @@ import type { ServeReadiness } from '../server/serve-readiness'
|
||||
export const ORCAD_READINESS_FILENAME = '.orcad-readiness'
|
||||
/** Stderr, including the bind-exposure line and every supervision message. */
|
||||
export const ORCAD_LOG_FILENAME = 'orcad.log'
|
||||
export { ORCAD_PID_FILENAME, OrcadRemoteLaunchUnsupportedError } from './orcad-remote-host-support'
|
||||
export {
|
||||
ORCAD_PID_FILENAME,
|
||||
OrcadRemoteLaunchUnsupportedError
|
||||
} from './orcad-remote-host-support'
|
||||
|
||||
export type OrcadLaunchSpec = {
|
||||
remoteInstallDir: string
|
||||
@@ -48,9 +51,7 @@ export type OrcadLaunchSpec = {
|
||||
export function orcadLaunchCommand(host: RemoteHostPlatform, spec: OrcadLaunchSpec): string {
|
||||
assertPosixHost(host)
|
||||
const dir = shellEscape(spec.remoteInstallDir)
|
||||
const readiness = shellEscape(
|
||||
joinRemotePath(host, spec.remoteInstallDir, ORCAD_READINESS_FILENAME)
|
||||
)
|
||||
const readiness = shellEscape(joinRemotePath(host, spec.remoteInstallDir, ORCAD_READINESS_FILENAME))
|
||||
const log = shellEscape(joinRemotePath(host, spec.remoteInstallDir, ORCAD_LOG_FILENAME))
|
||||
const pidFile = shellEscape(joinRemotePath(host, spec.remoteInstallDir, ORCAD_PID_FILENAME))
|
||||
const entry = shellEscape(joinRemotePath(host, spec.remoteInstallDir, 'orcad.js'))
|
||||
|
||||
@@ -13,7 +13,10 @@ vi.mock('./ssh-relay-install-transfers', () => ({
|
||||
import { execCommand } from './ssh-relay-deploy-helpers'
|
||||
import { writeRelayFile } from './ssh-relay-install-transfers'
|
||||
import { rollbackOrcad, type OrcadRollbackOptions } from './orcad-remote-rollback'
|
||||
import { emptyOrcadActivationRecord, type OrcadActivationRecord } from './orcad-activation-record'
|
||||
import {
|
||||
emptyOrcadActivationRecord,
|
||||
type OrcadActivationRecord
|
||||
} from './orcad-activation-record'
|
||||
import { getRemoteHostPlatform } from './ssh-remote-platform'
|
||||
import type { SshConnection } from './ssh-connection'
|
||||
|
||||
|
||||
@@ -109,7 +109,9 @@ async function readStateWritesSinceActivation(
|
||||
return newest === null ? null : newest >= activatedAtSeconds
|
||||
}
|
||||
|
||||
export async function rollbackOrcad(options: OrcadRollbackOptions): Promise<OrcadRollbackResult> {
|
||||
export async function rollbackOrcad(
|
||||
options: OrcadRollbackOptions
|
||||
): Promise<OrcadRollbackResult> {
|
||||
const now = options.now ?? ((): Date => new Date())
|
||||
const snapshotPresent = options.record.snapshot
|
||||
? (
|
||||
@@ -181,7 +183,11 @@ export async function rollbackOrcad(options: OrcadRollbackOptions): Promise<Orca
|
||||
}
|
||||
}
|
||||
|
||||
const targetDir = computeRemoteInstallDir(ORCAD_INSTALL_MODEL, options.remoteHome, safety.target)
|
||||
const targetDir = computeRemoteInstallDir(
|
||||
ORCAD_INSTALL_MODEL,
|
||||
options.remoteHome,
|
||||
safety.target
|
||||
)
|
||||
await exec(
|
||||
options,
|
||||
orcadLaunchCommand(options.host, {
|
||||
|
||||
@@ -143,9 +143,9 @@ describe('liveness and stop commands, run for real', () => {
|
||||
const exited = new Promise<NodeJS.Signals | null>((resolve) =>
|
||||
child.once('exit', (_code, signal) => resolve(signal))
|
||||
)
|
||||
expect(
|
||||
parseOrcadStopOutcome(sh(stopOrcadCommand(host, versionDir, { waitSeconds: 10 })))
|
||||
).toBe('stopped')
|
||||
expect(parseOrcadStopOutcome(sh(stopOrcadCommand(host, versionDir, { waitSeconds: 10 })))).toBe(
|
||||
'stopped'
|
||||
)
|
||||
expect(await exited).toBe('SIGTERM')
|
||||
expect(parseOrcadLiveness(sh(orcadLivenessProbeCommand(host, versionDir)))).toBe('DEAD')
|
||||
} finally {
|
||||
|
||||
@@ -211,9 +211,7 @@ async function isCandidateSafeToRemove(
|
||||
if (!(await isRelayInstallLockStale(conn, lockDir, host))) {
|
||||
return false
|
||||
}
|
||||
process.stderr.write?.(
|
||||
`[${model.id}] GC: lock at ${lockDir} is stale; treating as recoverable\n`
|
||||
)
|
||||
process.stderr.write?.(`[${model.id}] GC: lock at ${lockDir} is stale; treating as recoverable\n`)
|
||||
}
|
||||
|
||||
// Legacy dirs predate .install-complete; skip the sentinel and rely on the live-socket probe alone.
|
||||
@@ -233,6 +231,7 @@ async function isCandidateSafeToRemove(
|
||||
return !(await options.isDirLive(dir))
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The relay's GC, bound to its own namespace and its own liveness probe (a live unix socket
|
||||
* or Windows pipe inside the version dir).
|
||||
|
||||
@@ -92,11 +92,7 @@ export function computeRemoteInstallDir(
|
||||
pathFlavor === 'windows'
|
||||
? getRemoteHostPlatform('win32-x64')
|
||||
: getRemoteHostPlatform('linux-x64')
|
||||
return joinRemotePath(
|
||||
host,
|
||||
remoteHome,
|
||||
...remoteInstallDirSegments(model, fullVersion, pathFlavor)
|
||||
)
|
||||
return joinRemotePath(host, remoteHome, ...remoteInstallDirSegments(model, fullVersion, pathFlavor))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user