MCPcopy Create free account
hub / github.com/Gan-Xing/CodexBridge / acquireServeLock

Function acquireServeLock

src/cli.ts:719–739  ·  view source on GitHub ↗
(lockPath: string)

Source from the content-addressed store, hash-verified

717}
718
719async function acquireServeLock(lockPath: string): Promise<ServeLock> {
720 await fsp.mkdir(path.dirname(lockPath), { recursive: true });
721 try {
722 return await createServeLock(lockPath);
723 } catch (error) {
724 if (!(error && typeof error === 'object' && 'code' in error) || error.code !== 'EEXIST') {
725 throw error;
726 }
727 }
728
729 const existing = readServeLock(lockPath);
730 if (existing?.pid && isProcessAlive(existing.pid)) {
731 throw new Error(createI18n().t('cli.lock.alreadyRunning', {
732 lockPath,
733 pid: existing.pid,
734 }));
735 }
736
737 await fsp.rm(lockPath, { force: true });
738 return createServeLock(lockPath);
739}
740
741async function createServeLock(lockPath: string): Promise<ServeLock> {
742 const handle = await fsp.open(lockPath, 'wx');

Callers 3

cli.test.tsFile · 0.85
runWeixinServeFunction · 0.85
runCodexNativeApiServeFunction · 0.85

Calls 5

createServeLockFunction · 0.85
readServeLockFunction · 0.85
isProcessAliveFunction · 0.85
createI18nFunction · 0.85
tMethod · 0.65

Tested by

no test coverage detected