npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fillock

v0.0.10

Published

A utility to provide resource locking outside of the node process. Using file based locks.

Downloads

16

Readme

Fillock

Build Status Codacy Badge

Summary

This is a home built locking tool designed to be able to lock outside of the node process. It uses a lock file to determine how long a lock should persist. The original use case was that I had a process that I wanted to ensure was only running once. So I check the lock at startup and exit if it can't grab the lock.

Usage

To use Fillock, there are two main components to keeping track of a lock. First, a file name which will be used as a location to create a file to be used as the lock itself. Second, an id is used to determine if this process has the current lock.

This is a very simple paradigm, the example is that you have 4 applications, if A & B are dependent on the same resources and C & D are also dependent on the same resources (but different resources from A & B) you would think of the lock file as the designator for the resource, and the id as the designator for the process. In this example you could use Lock Files ".ResAB" and ".ResCD" and the process letter as the id. In this manner when A locks ".ResAB", B would be unavailable to lock, but C or D would still be able to get the lock on ".ResCD"

Get a lock

/*
 Attempt to get a lock
    id - ID of current process
    lock_file - lock file for specific resources.
    Returns Boolean of whether the lock was acquired.
*/
fillock.getLock(id, lock_file);

Update a lock

/*
 Attempt to update a lock. *Note this will try to get a lock if one doesn't already exist.
    id - ID of current process
    lock_file - lock file for specific resources.
    Returns Boolean of whether the lock was updated successfully.
*/
fillock.updateLock(id, lock_file);

Release a lock

/*
 Attempt to release the current lock.
    id - ID of current process
    lock_file - lock file for specific resources.
    Returns Boolean of whether the lock was released successfully.
*/
fillock.unLock(id, lock_file);

Start Auto Updating

/*
 Turn on Auto Updating, attempt to update the lock at the given timeout automatically.
    timeout - Integer Milliseconds as the update interval
    id - ID of current process
    lock_file - lock file for specific resources.
*/
fillock.startAutoUpdate(timeout, id, lock_file);

Stop Auto Updating

/*
 Turn off auto updating.
*/
fillock.stopAutoUpdate();

Check for Existing Lock

/*
 Check if the lock exists for the current process. *Note this will not update or do any modification of the lock.
    id - ID of current process
    lock_file - lock file for specific resources.
    Returns Boolean of whether this process has a lock or not.
*/
fillock.hasLock(id, lock_file);

Author

Seth Thompson

Change Log

  • v0.0.1 - First Commit - 12/15/2014
  • v0.0.2 - Rename to fillock for publish to npm - 02/12/2015
  • v0.0.6 - Fix npm repository stuff.
  • v0.0.7 - Set Current State on first retrieval.
  • v0.0.8 - Bugfix hasLock to properly determine if the lock is still valid. A lock is no longer considered valid if the it has expired. Added tests and debug logging.
  • v0.0.9 - Bugfix getLock will now take over an existing lockFile if one already exists but has drifted past being valid.
  • v0.0.10 - Bugfix to the bugfix =( added tests.