@ac-essentials/misc-util
    Preparing search index...

    Class UdpBindLock

    A class that provides a mechanism to ensure that only one instance of a process is running at a time by attempting to bind to a specific UDP port.

    This is useful for preventing multiple instances of a script or application from running simultaneously.

    Note: The lock is automatically released when the process exits, but it is recommended to call releaseLock explicitly when the lock is no longer needed.

    Example usage:

    const lock = new ProcessLock({
    udpSocketType: "udp4",
    udpBindPort: 12345,
    });

    const acquired = await lock.tryAcquireLock();
    if (!acquired) {
    console.error("Another instance is already running.");
    process.exit(1);
    }

    // ... application logic ...

    await lock.releaseLock();

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Accessors

    Methods

    Constructors

    Accessors

    Methods