refactor(compute-worker): improve docstore directory resolution logic
Update resolveDocstoreDir to handle multiple environments: - Prefer monorepo root for local development - Check process.env.PWD for containerized bootstrap - Fallback to standard /app/docstore path - Default to process cwd Enhances robustness of docstore path resolution across deployment scenarios.
This commit is contained in:
parent
6b13a3394b
commit
74a96c0d15
1 changed files with 15 additions and 0 deletions
|
|
@ -14,8 +14,23 @@ function findMonorepoRoot(startDir: string): string | null {
|
|||
}
|
||||
|
||||
function resolveDocstoreDir(): string {
|
||||
// 1. Try to find the monorepo root (works in local development)
|
||||
const repoRoot = findMonorepoRoot(process.cwd());
|
||||
if (repoRoot) return path.join(repoRoot, 'docstore');
|
||||
|
||||
// 2. In a containerized environment, the parent bootstrap process runs in /app
|
||||
// and the child process inherits process.env.PWD = '/app'.
|
||||
if (process.env.PWD) {
|
||||
const pwdDocstore = path.join(process.env.PWD, 'docstore');
|
||||
if (fs.existsSync(pwdDocstore)) return pwdDocstore;
|
||||
}
|
||||
|
||||
// 3. Fallback to the standard container app docstore path if it exists
|
||||
if (fs.existsSync('/app/docstore')) {
|
||||
return '/app/docstore';
|
||||
}
|
||||
|
||||
// 4. Fallback to the process cwd docstore
|
||||
return path.join(process.cwd(), 'docstore');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue