tcp-mutex

1.0.1 • Public • Published

tcp-mutex

This small library is there to acquire a tcp based lock by opening a tcp-server. Since ports cannot be listened from more than 1 process we can use this behaviour to acquire a kind of lock based on port.

Usage

npm install tcp-mutex --save

var {tryLock} = require('tcp-mutex');

tryLock(1337).then((success)=>{
    console.log("locked successfully");
    // we can start our application here
}).catch(err=>{
    console.log("This application already started");
    process.exit(0);
});

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    691
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    691
  • 1.0.0
    1

Package Sidebar

Install

npm i tcp-mutex

Weekly Downloads

687

Version

1.0.1

License

MIT

Last publish

Collaborators

  • vpn1