fix(code-queue): sync codex auth into runtime home
This commit is contained in:
@@ -77,6 +77,7 @@ services:
|
||||
- ${CODE_QUEUE_WORKSPACE_PATH:-../../../..}:/root/unidesk
|
||||
- ${CODE_QUEUE_WORKSPACE_PATH:-../../../..}:/workspace
|
||||
- ${CODE_QUEUE_CODEX_CONFIG_PATH:-/home/ubuntu/.codex/config.toml}:/root/.codex/config.toml:ro
|
||||
- ${CODE_QUEUE_CODEX_AUTH_PATH:-/home/ubuntu/.codex/auth.json}:/root/.codex/auth.json:ro
|
||||
- ${CODE_QUEUE_SSH_DIR:-/home/ubuntu/.ssh}:/root/.ssh:ro
|
||||
- ${CODE_QUEUE_LOG_DIR:-../../../../.state/code-queue/logs}:/var/log/unidesk
|
||||
- ${CODE_QUEUE_STATE_DIR:-../../../../.state/code-queue}:/var/lib/unidesk/code-queue
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 重构前 index.ts 只读参考:commit 6a04144d3f5103014f75b637d7e6bc2f45bf007f,blob 56e590c1a6b5ca7ad128bf2c992f60e46c355a58;可用 `git show 6a04144d3f5103014f75b637d7e6bc2f45bf007f:src/components/microservices/code-queue/src/index.ts` 查看。
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { Database } from "bun:sqlite";
|
||||
import postgres from "postgres";
|
||||
import { createHourlyJsonlWriter, logRetentionBytesForService } from "../../../shared/src/rotating-jsonl";
|
||||
@@ -1702,6 +1702,12 @@ function prepareCodexHome(): void {
|
||||
} else {
|
||||
logger("warn", "codex_config_source_missing", { sourceCodexConfig: config.sourceCodexConfig });
|
||||
}
|
||||
const sourceCodexAuth = resolve(dirname(config.sourceCodexConfig), "auth.json");
|
||||
if (existsSync(sourceCodexAuth)) {
|
||||
copyFileSync(sourceCodexAuth, resolve(config.codexHome, "auth.json"));
|
||||
} else {
|
||||
logger("warn", "codex_auth_source_missing", { sourceCodexAuth });
|
||||
}
|
||||
}
|
||||
|
||||
function openCodeXdgEnv(root = config.opencodeXdgDir): Record<string, string> {
|
||||
@@ -1769,7 +1775,10 @@ function collectDevReady(): JsonValue {
|
||||
const composeProbe = runProbe("docker", ["compose", "version"]);
|
||||
const workdirExists = existsSync(config.defaultWorkdir);
|
||||
const dockerSocketExists = existsSync("/var/run/docker.sock");
|
||||
const codexConfigReady = existsSync(config.sourceCodexConfig) || existsSync(resolve(config.codexHome, "config.toml"));
|
||||
const homeCodexConfig = resolve(config.codexHome, "config.toml");
|
||||
const sourceCodexAuth = resolve(dirname(config.sourceCodexConfig), "auth.json");
|
||||
const homeCodexAuth = resolve(config.codexHome, "auth.json");
|
||||
const codexConfigReady = existsSync(config.sourceCodexConfig) || existsSync(homeCodexConfig);
|
||||
const sshKeyProbe = runProbe("sh", ["-lc", "test -d /root/.ssh && find /root/.ssh -maxdepth 1 -type f \\( -name 'id_*' ! -name '*.pub' \\) -perm -400 -print -quit"]);
|
||||
const githubKnownHostProbe = runProbe("ssh-keygen", ["-F", "github.com", "-f", "/root/.ssh/known_hosts"]);
|
||||
const sshSharedReady = existsSync("/root/.ssh") && sshKeyProbe.ok && sshKeyProbe.output.trim().length > 0;
|
||||
@@ -1790,8 +1799,12 @@ function collectDevReady(): JsonValue {
|
||||
codexConfig: {
|
||||
sourcePath: config.sourceCodexConfig,
|
||||
sourceExists: existsSync(config.sourceCodexConfig),
|
||||
homeConfigPath: resolve(config.codexHome, "config.toml"),
|
||||
homeConfigExists: existsSync(resolve(config.codexHome, "config.toml")),
|
||||
homeConfigPath: homeCodexConfig,
|
||||
homeConfigExists: existsSync(homeCodexConfig),
|
||||
sourceAuthPath: sourceCodexAuth,
|
||||
sourceAuthExists: existsSync(sourceCodexAuth),
|
||||
homeAuthPath: homeCodexAuth,
|
||||
homeAuthExists: existsSync(homeCodexAuth),
|
||||
ready: codexConfigReady,
|
||||
},
|
||||
ssh: {
|
||||
|
||||
@@ -393,6 +393,9 @@ spec:
|
||||
- name: codex-config
|
||||
mountPath: /root/.codex/config.toml
|
||||
readOnly: true
|
||||
- name: codex-auth
|
||||
mountPath: /root/.codex/auth.json
|
||||
readOnly: true
|
||||
- name: ssh-dir
|
||||
mountPath: /root/.ssh
|
||||
readOnly: true
|
||||
@@ -440,6 +443,10 @@ spec:
|
||||
hostPath:
|
||||
path: /home/ubuntu/.codex/config.toml
|
||||
type: File
|
||||
- name: codex-auth
|
||||
hostPath:
|
||||
path: /home/ubuntu/.codex/auth.json
|
||||
type: File
|
||||
- name: ssh-dir
|
||||
hostPath:
|
||||
path: /home/ubuntu/.ssh
|
||||
@@ -619,6 +626,9 @@ spec:
|
||||
- name: codex-config
|
||||
mountPath: /root/.codex/config.toml
|
||||
readOnly: true
|
||||
- name: codex-auth
|
||||
mountPath: /root/.codex/auth.json
|
||||
readOnly: true
|
||||
- name: ssh-dir
|
||||
mountPath: /root/.ssh
|
||||
readOnly: true
|
||||
@@ -666,6 +676,10 @@ spec:
|
||||
hostPath:
|
||||
path: /home/ubuntu/.codex/config.toml
|
||||
type: File
|
||||
- name: codex-auth
|
||||
hostPath:
|
||||
path: /home/ubuntu/.codex/auth.json
|
||||
type: File
|
||||
- name: ssh-dir
|
||||
hostPath:
|
||||
path: /home/ubuntu/.ssh
|
||||
|
||||
Reference in New Issue
Block a user