UNPKG

rex-server

Version:

Rex Server is a Node.js-based reverse proxy server available as an npm package. It allows you to handle HTTP and HTTPS traffic, route requests to upstream servers, and manage worker processes efficiently. With its CLI interface, Rex makes it easy to confi

53 lines (52 loc) 2.48 kB
/** * Writes the Process ID (PID) to a specified file. * * This function checks if the PID file exists. If it does, it writes the provided PID value to the file. * The operation is done asynchronously, and a promise is returned to indicate the completion of the task. * * @param {string} processIdPath - The file path where the PID will be stored. * @param {string} pid - The Process ID to write to the file. * @returns {Promise<void>} - A promise that resolves when the file has been written successfully. * * @throws {Error} Will throw an error if the PID file doesn't exist or if the write operation fails. * * @example * writePid("/path/to/pidfile.pid", "12345") * .then(() => console.log("PID written successfully")) * .catch(error => console.error("Error writing PID:", error)); */ export declare function writePid(processIdPath: string, pid: string): Promise<void>; /** * Reads the Process ID (PID) from a specified file. * * This function checks if the PID file exists, and if so, reads the PID value stored in the file. * The read operation is asynchronous and returns a promise that resolves with the PID string. * * @param {string} processIdPath - The file path where the PID is stored. * @returns {Promise<string>} - A promise that resolves with the PID string stored in the file. * * @throws {Error} Will throw an error if the file doesn't exist or if the read operation fails. * * @example * readPid("/path/to/pidfile.pid") * .then(pid => console.log("PID:", pid)) * .catch(error => console.error("Error reading PID:", error)); */ export declare function readPid(processIdPath: string): Promise<string>; /** * Checks if the PID file exists at the specified path. * * This function checks the existence of the PID file at the specified path. If the file doesn't exist, * it throws an error with instructions on how to resolve the issue, including steps to restart processes or reinstall the server. * * @param {string} processIdPath - The file path to check for the PID file. * @returns {Promise<void>} - A promise that resolves if the file exists, otherwise throws an error. * * @throws {Error} Will throw an error if the file doesn't exist, with troubleshooting instructions. * * @example * doesPidExists("/path/to/pidfile.pid") * .then(() => console.log("PID file exists")) * .catch(error => console.error("Error:", error)); */ export declare function doesPidExists(processIdPath: string): Promise<void>;