| hide_title | true |
|---|---|
| custom_edit_url | |
| pagination_prev | |
| pagination_next |
Home > @rushstack/node-core-library > LockFile
The LockFile implements a file-based mutex for synchronizing access to a shared resource between multiple Node.js processes. It is not recommended for synchronization solely within a single Node.js process.
Signature:
export declare class LockFile The implementation works on Windows, Mac, and Linux without requiring any native helpers. On non-Windows systems, the algorithm requires access to the ps shell command. On Linux, it requires access the /proc/${pidString}/stat filesystem.
|
Property |
Modifiers |
Type |
Description |
|---|---|---|---|
|
|
boolean |
Returns the initial state of the lock. This can be used to detect if the previous process was terminated before releasing the resource. | |
|
|
string |
Returns the absolute path to the lockfile | |
|
|
boolean |
Returns true if this lock is currently being held. |
|
Method |
Modifiers |
Description |
|---|---|---|
|
| ||
|
|
Attempts to create the lockfile. Will continue to loop at every 100ms until the lock becomes available or the maxWaitMs is surpassed. | |
|
|
Returns the path of the lockfile that will be created when a lock is successfully acquired. | |
|
Unlocks a file and optionally removes it from disk. This can only be called once. | ||
|
|
Attempts to create a lockfile with the given filePath. |