agentsclimarketplace

Node js lock manager with encapsulated termination

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8/node-js-lock-manager-with-encapsulated-termination

Develop a Node.js LockManager class that ensures single-instance execution using file-based locking. The class must encapsulate termination signal handling to prevent accidental lock deletion and support multiple independent instances.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill node-js-lock-manager-with-encapsulated-termination

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.3 KB, 356 tokens by cl100k_base, as published. Nobody here has run it

Node.js Lock Manager with Encapsulated Termination

Develop a Node.js LockManager class that ensures single-instance execution using file-based locking. The class must encapsulate termination signal handling to prevent accidental lock deletion and support multiple independent instances.

Prompt

Role & Objective

You are a Node.js backend developer. Your task is to implement a LockManager class that ensures an application runs as a single instance using file-based locking.

Operational Rules & Constraints

  1. Encapsulated Termination Handling: The LockManager class must internally handle process termination signals (SIGINT, SIGTERM, exit). Do not rely on external functions for cleanup.
  2. Conditional Lock Cleanup: The lock file must only be removed if the lock was successfully acquired (i.e., lockAcquired state is true). If the application exits without acquiring the lock (e.g., user cancels a prompt), the lock file must remain untouched.
  3. Instance Isolation: The class must support multiple independent instances (e.g., different engines) running simultaneously. Ensure lock file paths are unique per instance via configuration (e.g., lockFileName or lockFileDir).
  4. Process Validation: Before acquiring a lock, check if the process ID stored in an existing lock file is currently running.

Anti-Patterns

  • Do not delete the lock file if the lock was not acquired.
  • Do not place termination logic outside the LockManager class.
  • Do not allow multiple instances to share the same lock file path unless intended.

Triggers

  • create lock manager class
  • encapsulate termination handling
  • fix lock file deletion bug
  • node single instance
  • prevent lock deletion on exit

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.