( versionPath: string, lockFilePath: string, )
| 297 | * This is used for locking the currently running version |
| 298 | */ |
| 299 | export async function acquireProcessLifetimeLock( |
| 300 | versionPath: string, |
| 301 | lockFilePath: string, |
| 302 | ): Promise<boolean> { |
| 303 | const release = await tryAcquireLock(versionPath, lockFilePath) |
| 304 | |
| 305 | if (!release) { |
| 306 | return false |
| 307 | } |
| 308 | |
| 309 | // Register cleanup on process exit |
| 310 | const cleanup = () => { |
| 311 | try { |
| 312 | release() |
| 313 | } catch { |
| 314 | // Ignore errors during process exit |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | process.on('exit', cleanup) |
| 319 | process.on('SIGINT', cleanup) |
| 320 | process.on('SIGTERM', cleanup) |
| 321 | |
| 322 | // Don't call release() - we want to hold the lock until process exits |
| 323 | return true |
| 324 | } |
| 325 | |
| 326 | /** |
| 327 | * Execute a callback while holding a lock |
no test coverage detected