MCPcopy
hub / github.com/garrytan/gstack / acquireDreamMarker

Function acquireDreamMarker

bin/gstack-gbrain-sync.ts:663–685  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

661 * Mirrors acquireLock but with the dream TTL and its own path.
662 */
663export function acquireDreamMarker(): boolean {
664 const path = dreamMarkerPath();
665 mkdirSync(dirname(path), { recursive: true });
666 if (existsSync(path)) {
667 try {
668 const stat = statSync(path);
669 if (Date.now() - stat.mtimeMs > DREAM_MARKER_STALE_MS) {
670 unlinkSync(path);
671 } else {
672 return false;
673 }
674 } catch {
675 return false;
676 }
677 }
678 const info: LockInfo = { pid: process.pid, started_at: new Date().toISOString() };
679 try {
680 writeFileSync(path, JSON.stringify(info), { encoding: "utf-8", flag: "wx" });
681 return true;
682 } catch {
683 return false;
684 }
685}
686
687export function releaseDreamMarker(): void {
688 try {

Callers 2

runDreamFunction · 0.85

Calls 1

dreamMarkerPathFunction · 0.85

Tested by

no test coverage detected