lock server written in node.js
This is lock server for system that need to share and lock common resources across servers with sub-second precision.
It allows to set wait timeout for lock and max execution time to limit your desire for eternal locking.
Client for node.js is completely async.
var Locker = require"locker"locker = 4545 "127.0.0.1";lockeron"reset"console.log"Reset happened (is server running?)";;lockeron"error"console.log"Catched error:" error;;// name wait max callbacklockerlocked"five" 2000 3000if error// lock failedcallbackerror;return;// do whatever you want with your shared resourcecallbackundefined well: "done";;
First create a dir for locker:
mkdir lockercd lockermkdir node_modulesnpm install locker-server
Then create main server file (look at
example/server.js) and save it as
var Locker = require"../index"locker = ;lockerlisten4545;;
Run it after all: