refactor(docstore): improve docstore directory resolution for monorepo setups
Refactored docstore directory logic to dynamically locate the monorepo root by searching for a pnpm-workspace.yaml marker. If found, the docstore directory is anchored at the monorepo root; otherwise, it defaults to the current working directory. This enhances consistency when running in different environments. Also updated process shutdown and SeaweedFS launch arguments in the entrypoint script for improved reliability and log filtering.
This commit is contained in:
parent
02979a98af
commit
e5ee621288
2 changed files with 26 additions and 4 deletions
|
|
@ -1,6 +1,24 @@
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
export const DOCSTORE_DIR = path.join(process.cwd(), 'docstore');
|
||||
function findMonorepoRoot(startDir: string): string | null {
|
||||
let current = path.resolve(startDir);
|
||||
for (;;) {
|
||||
const marker = path.join(current, 'pnpm-workspace.yaml');
|
||||
if (fs.existsSync(marker)) return current;
|
||||
const parent = path.dirname(current);
|
||||
if (parent === current) return null;
|
||||
current = parent;
|
||||
}
|
||||
}
|
||||
|
||||
function resolveDocstoreDir(): string {
|
||||
const repoRoot = findMonorepoRoot(process.cwd());
|
||||
if (repoRoot) return path.join(repoRoot, 'docstore');
|
||||
return path.join(process.cwd(), 'docstore');
|
||||
}
|
||||
|
||||
export const DOCSTORE_DIR = resolveDocstoreDir();
|
||||
|
||||
export function getDocstoreDir(): string {
|
||||
return DOCSTORE_DIR;
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ async function main() {
|
|||
shutdownPromise = (async () => {
|
||||
await Promise.all([
|
||||
terminateChild(appProc, signal, 4000),
|
||||
terminateChild(workerProc, 'SIGTERM', 4000, true),
|
||||
terminateChild(workerProc, 'SIGTERM', 4000),
|
||||
terminateChild(natsProc, 'SIGTERM', 4000),
|
||||
terminateChild(weedProc, 'SIGTERM', 4000),
|
||||
]);
|
||||
|
|
@ -397,7 +397,12 @@ async function main() {
|
|||
const waitTimeout = Number.isFinite(waitSec) ? waitSec : 20;
|
||||
const launchWeed = (endpointUrl) => {
|
||||
const parsedEndpoint = parseS3Endpoint(endpointUrl);
|
||||
const weedArgs = ['mini', `-dir=${runtimeEnv.WEED_MINI_DIR}`];
|
||||
const weedArgs = [
|
||||
'-alsologtostderr=false',
|
||||
'-stderrthreshold=WARNING',
|
||||
'mini',
|
||||
`-dir=${runtimeEnv.WEED_MINI_DIR}`,
|
||||
];
|
||||
weedArgs.push(`-s3.port=${parsedEndpoint.port}`);
|
||||
if (runningInDocker) {
|
||||
weedArgs.push('-ip.bind=0.0.0.0');
|
||||
|
|
@ -512,7 +517,6 @@ async function main() {
|
|||
env: workerEnv,
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
shell: process.platform === 'win32',
|
||||
detached: process.platform !== 'win32',
|
||||
},
|
||||
);
|
||||
stopWorkerStdoutForward = forwardChildStream(workerProc.stdout, process.stdout);
|
||||
|
|
|
|||
Loading…
Reference in a new issue