ProcessPidFile
Defined in: packages/app-system/src/process/process-pid-file.ts:28
Class to manage a PID file for the current process.
This class provides methods to write the current process PID to a specified file and to remove the PID file when it is no longer needed.
Note: The PID file is automatically removed when the process exits, if it was created by this class instance.
Example usage:
const pidFile = new ProcessPidFile("/var/run/myapp.pid");await pidFile.write();// ... application logic ...await pidFile.remove();Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ProcessPidFile(
filePath):ProcessPidFile
Defined in: packages/app-system/src/process/process-pid-file.ts:31
Parameters
Section titled “Parameters”filePath
Section titled “filePath”string
Returns
Section titled “Returns”ProcessPidFile
Methods
Section titled “Methods”remove()
Section titled “remove()”remove():
Promise<void>
Defined in: packages/app-system/src/process/process-pid-file.ts:57
Removes the PID file if it exists and cleans up the exit handler.
Returns
Section titled “Returns”Promise<void>
write()
Section titled “write()”write():
Promise<void>
Defined in: packages/app-system/src/process/process-pid-file.ts:43
Writes the current process PID to the PID file and sets up a handler to remove the PID file on process exit.
Note: If the process crashes or is forcefully terminated, the PID file may not be removed. In such cases, manual cleanup may be necessary.
This method ensures that the directory for the PID file exists before writing the file.
Returns
Section titled “Returns”Promise<void>