@runeditrun/rer 0.2.20 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/README.md +7 -0
- package/cli/demo-host.mjs +9 -8
- package/cli/demo-removal-provider.mjs +24 -0
- package/cli/deploy-command.mjs +10 -7
- package/cli/deploy-hook.mjs +10 -14
- package/cli/deploy.mjs +3 -1
- package/cli/export.mjs +1 -1
- package/cli/managed-server.mjs +5 -2
- package/cli/production-auth.mjs +19 -5
- package/global/CHANGELOG.md +7 -1
- package/modules/container/README.md +10 -0
- package/modules/container/build.mjs +10 -12
- package/modules/container/host.mjs +3 -1
- package/modules/container/ingress.mjs +15 -4
- package/modules/container/migration-inventory.mjs +33 -0
- package/modules/container/migrations.mjs +16 -2
- package/modules/delivery-producer/migrations.mjs +61 -0
- package/modules/demo/effects.mjs +4 -0
- package/modules/demo-host/README.md +34 -15
- package/modules/demo-host/capacity.mjs +1 -1
- package/modules/demo-host/container.mjs +73 -39
- package/modules/demo-host/diagnostics.mjs +1 -0
- package/modules/demo-host/pages.mjs +1 -1
- package/modules/demo-host/placement.mjs +23 -0
- package/modules/demo-host/plan.mjs +20 -7
- package/modules/demo-host/remove.mjs +9 -7
- package/modules/demo-host/start-script.mjs +10 -1
- package/modules/demo-host/startup.mjs +4 -2
- package/modules/demo-host/worker.mjs +18 -1
- package/modules/dependencies/approval.mjs +3 -2
- package/modules/dependencies/index.mjs +2 -2
- package/modules/deploy-kit/README.md +16 -2
- package/modules/deploy-kit/diagnostics.mjs +9 -0
- package/modules/deploy-kit/health-request.mjs +7 -5
- package/modules/deploy-kit/provider-transport.mjs +56 -0
- package/modules/deploy-kit/provider.mjs +22 -20
- package/modules/operator-auth/README.md +4 -0
- package/modules/operator-auth/accounts/credentials.mjs +2 -2
- package/modules/operator-auth/accounts/email-change.mjs +2 -2
- package/modules/operator-auth/accounts/provider-control.mjs +3 -3
- package/modules/operator-auth/accounts/store.mjs +9 -8
- package/modules/operator-auth/dev/cli-session.mjs +5 -4
- package/modules/operator-auth/dev/index.mjs +5 -5
- package/modules/operator-auth/dev-gate.mjs +4 -2
- package/modules/operator-auth/identity/email-link/index.mjs +2 -1
- package/modules/operator-auth/signin/index.mjs +10 -2
- package/onboarding/adapter.mjs +11 -3
- package/onboarding/operator-installer.mjs +2 -2
- package/onboarding/operator-migrations.mjs +48 -0
- package/onboarding/process-table.mjs +45 -19
- package/package.json +1 -1
|
@@ -7,6 +7,21 @@ const execute = promisify(execFile)
|
|
|
7
7
|
// One bounded wait for any process inspection; a loaded machine can take over a
|
|
8
8
|
// second to list processes, which must not abort an otherwise healthy cleanup.
|
|
9
9
|
export const inspectionMs = 5000
|
|
10
|
+
// A snapshot taken while processes start or exit can hold a row ps has not yet
|
|
11
|
+
// finished, or ps itself can fail for an instant. Such a read says nothing
|
|
12
|
+
// about ownership; it is repeated within the same bound rather than ending a
|
|
13
|
+
// launch whose own processes are accounted for.
|
|
14
|
+
const transient = (message) => Object.assign(new Error(message), { transient: true })
|
|
15
|
+
const retryMs = 10
|
|
16
|
+
async function withinBound(timeout, attempt) {
|
|
17
|
+
const deadline = Date.now() + timeout
|
|
18
|
+
for (;;) {
|
|
19
|
+
try { return await attempt(Math.max(1, deadline - Date.now())) } catch (error) {
|
|
20
|
+
if (!error.transient || Date.now() + retryMs >= deadline) throw error
|
|
21
|
+
await delay(retryMs)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
10
25
|
export const validPid = (pid) => Number.isSafeInteger(pid) && pid > 0 && pid <= 0x7fffffff
|
|
11
26
|
|
|
12
27
|
// Inspect numeric identity and the executable name, never private argv.
|
|
@@ -60,20 +75,23 @@ async function processGroup(pgid, signal) {
|
|
|
60
75
|
}
|
|
61
76
|
return group
|
|
62
77
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
78
|
+
let stdout
|
|
79
|
+
try {
|
|
80
|
+
({ stdout } = await execute('/bin/ps', [
|
|
81
|
+
'-ax', '-o', 'pid=', '-o', 'ppid=', '-o', 'pgid=', '-o', 'uid=', '-o', 'stat=', '-o', 'lstart=',
|
|
82
|
+
], { env: { ...process.env, LC_ALL: 'C', TZ: 'UTC' }, signal, killSignal: 'SIGKILL', maxBuffer: 8 * 1024 * 1024 }))
|
|
83
|
+
} catch (error) { if (signal.aborted) throw error; throw transient('Could not read process identities.') }
|
|
66
84
|
const group = []
|
|
67
85
|
for (const line of stdout.split('\n').filter((line) => line.trim())) {
|
|
68
86
|
const match = line.match(/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(.{24})\s*$/)
|
|
69
|
-
if (!match) throw
|
|
87
|
+
if (!match) throw transient('Could not read process identities.')
|
|
70
88
|
const [, id, parent, groupId, uid, state, birth] = match
|
|
71
89
|
const pid = Number(id)
|
|
72
90
|
const ppid = Number(parent)
|
|
73
91
|
if (pgid === undefined && (pid === 0 || Number(groupId) === 0)) continue
|
|
74
92
|
if (pgid !== undefined && Number(groupId) !== pgid) continue
|
|
75
93
|
if (!validPid(pid) || !validPid(Number(groupId)) || !Number.isSafeInteger(ppid) || ppid < 0 || !Number.isFinite(Date.parse(birth))) {
|
|
76
|
-
throw
|
|
94
|
+
throw transient('Invalid process identity.')
|
|
77
95
|
}
|
|
78
96
|
group.push({ pid, ppid, pgid: Number(groupId), uid: Number(uid), state, birth })
|
|
79
97
|
}
|
|
@@ -86,30 +104,38 @@ async function processGroup(pgid, signal) {
|
|
|
86
104
|
export async function readProcessIdentity(pid, timeout = inspectionMs) {
|
|
87
105
|
if (!validPid(pid) || !(timeout > 0)) throw new Error('Invalid process identity deadline.')
|
|
88
106
|
if (process.platform === 'linux') return linuxProcess(pid, undefined, AbortSignal.timeout(timeout))
|
|
107
|
+
return withinBound(timeout, (remaining) => psIdentity(pid, remaining))
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function psIdentity(pid, timeout) {
|
|
89
111
|
let stdout
|
|
90
112
|
try {
|
|
91
113
|
({ stdout } = await execute('/bin/ps', ['-p', String(pid), '-o', 'pid=', '-o', 'ppid=', '-o', 'pgid=', '-o', 'uid=', '-o', 'stat=', '-o', 'lstart=', '-o', 'comm='],
|
|
92
114
|
{ env: { ...process.env, LC_ALL: 'C', TZ: 'UTC' }, timeout, killSignal: 'SIGKILL', maxBuffer: 1024 * 1024 }))
|
|
93
|
-
} catch (error) { if (error.code === 1 && !error.stdout?.trim()) return; throw
|
|
115
|
+
} catch (error) { if (error.code === 1 && !error.stdout?.trim()) return; throw transient('Could not inspect process identity.') }
|
|
94
116
|
const match = stdout.match(/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(.{24})\s+(.+?)\s*$/)
|
|
95
|
-
if (!match) throw
|
|
117
|
+
if (!match) throw transient('Invalid process identity.')
|
|
96
118
|
const [, id, parent, groupId, uid, state, birth, command] = match
|
|
97
|
-
if (Number(id) !== pid || !validPid(Number(groupId)) || !Number.isFinite(Date.parse(birth + ' UTC'))) throw
|
|
119
|
+
if (Number(id) !== pid || !validPid(Number(groupId)) || !Number.isFinite(Date.parse(birth + ' UTC'))) throw transient('Invalid process identity.')
|
|
98
120
|
return { pid, ppid: Number(parent), pgid: Number(groupId), uid: Number(uid), state, birth, command }
|
|
99
121
|
}
|
|
100
122
|
|
|
101
|
-
|
|
123
|
+
// `read` is the process edge: it returns the table or throws; tests supply a
|
|
124
|
+
// failing one.
|
|
125
|
+
export async function readProcessTable(timeout = inspectionMs, pgid, read = processGroup) {
|
|
102
126
|
if (!(timeout > 0)) throw new Error('Process inspection deadline expired.')
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
127
|
+
return withinBound(timeout, async (remaining) => {
|
|
128
|
+
const controller = new AbortController()
|
|
129
|
+
let timer
|
|
130
|
+
try {
|
|
131
|
+
return await Promise.race([read(pgid, controller.signal), new Promise((_, reject) => {
|
|
132
|
+
timer = setTimeout(() => {
|
|
133
|
+
controller.abort()
|
|
134
|
+
reject(new Error('Process inspection deadline expired.'))
|
|
135
|
+
}, remaining)
|
|
136
|
+
})])
|
|
137
|
+
} finally { clearTimeout(timer) }
|
|
138
|
+
})
|
|
113
139
|
}
|
|
114
140
|
|
|
115
141
|
export const sameBirth = (left, right) => validPid(left?.pid) && left.pid === right?.pid && left.birth === right?.birth
|