(pidPath: string | undefined, pid: number)
| 75 | } |
| 76 | |
| 77 | export function writePidFile(pidPath: string | undefined, pid: number): void { |
| 78 | if (!pidPath) return; |
| 79 | const dir = path.dirname(pidPath); |
| 80 | if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true }); |
| 81 | const metadata: StoredAppLogProcessMeta = { |
| 82 | pid, |
| 83 | startTime: readProcessStartTime(pid) ?? undefined, |
| 84 | command: readProcessCommand(pid) ?? undefined, |
| 85 | }; |
| 86 | fs.writeFileSync(pidPath, `${JSON.stringify(metadata)}\n`); |
| 87 | } |
| 88 | |
| 89 | export function clearPidFile(pidPath: string | undefined): void { |
| 90 | if (!pidPath || !fs.existsSync(pidPath)) return; |
no test coverage detected