{"_id":"node-locksmith","_rev":"8-29875438fedad9f7075ca983693a8c57","name":"node-locksmith","dist-tags":{"latest":"1.0.8"},"versions":{"1.0.0":{"name":"node-locksmith","version":"1.0.0","description":"node-locksmith ensures that only a single instance of an application can run at once. It uses a lock file to maintain a system-level mutex.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"sai"},"license":"MIT","dependencies":{"ps-node":"^0.1.6"},"_id":"node-locksmith@1.0.0","gitHead":"0676ffa0d8d489d198f0a1276c81891533e5f949","_nodeVersion":"20.10.0","_npmVersion":"10.2.5","dist":{"integrity":"sha512-/r6CW97pPC0UGtqV4Q60r6G+kgdXWNQ1pN5X+5mnLvQG+CwRlRO7gk1zpiKtZcuo222hdt7WrovHT1fJbkZyhA==","shasum":"ffdf907f2c5baa47a3631c9032c98e8b7ccff046","tarball":"https://registry.npmjs.org/node-locksmith/-/node-locksmith-1.0.0.tgz","fileCount":6,"unpackedSize":58282,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGcBlI10oTzx0MIlHzIxYvJUB6nzJljp9E+94Lz27oOTAiEA1h9mjFXg3xIZmfBgXhBbsToSt8xW0Jece3nR+K6sF2o="}]},"_npmUser":{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"},"directories":{},"maintainers":[{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-locksmith_1.0.0_1702723897936_0.549116930181446"},"_hasShrinkwrap":false},"1.0.1":{"name":"node-locksmith","version":"1.0.1","description":"node-locksmith ensures that only a single instance of an application can run at once. It uses a lock file to maintain a system-level mutex.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"sai"},"license":"MIT","dependencies":{"ps-node":"^0.1.6"},"_id":"node-locksmith@1.0.1","gitHead":"d8f93368f7867af2054e4fa758c03dc7d7cdfd26","_nodeVersion":"20.10.0","_npmVersion":"10.2.5","dist":{"integrity":"sha512-ECls46U2DD6FLjr1Oh3WVZP+LhgTVgoIBWLShMRcAE7iVNkMuZqrAGzS5PTg9SWZGPnLRM264KALLR56jm5F5Q==","shasum":"8bb18bb5e95fac2731beff51dce36840c70c82c8","tarball":"https://registry.npmjs.org/node-locksmith/-/node-locksmith-1.0.1.tgz","fileCount":6,"unpackedSize":58236,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC4tVZ4AvWDAv4RXzFJYMJEZ1r2GIQmUoq9IEuig/0dMAIgfMaj8g46+BKyWl5wbhDVoeaJTpQoxbKvLqE+UH5f+m8="}]},"_npmUser":{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"},"directories":{},"maintainers":[{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-locksmith_1.0.1_1702724185099_0.3384875338937843"},"_hasShrinkwrap":false},"1.0.2":{"name":"node-locksmith","version":"1.0.2","description":"node-locksmith ensures that only a single instance of an application can run at once. It uses a lock file to maintain a system-level mutex.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"sai"},"license":"MIT","dependencies":{"ps-node":"^0.1.6"},"_id":"node-locksmith@1.0.2","gitHead":"04d8622fe253e6a5cbc559812781e9ed9a789ee4","_nodeVersion":"20.10.0","_npmVersion":"10.2.5","dist":{"integrity":"sha512-qhRo2d/4w5ro/hMqwOH+Mn6Mtd8tQwvz9Y1HkVDZqY5WL3m5GFS3TfvpHXzY0kTFafxniJ1bTLztKm+m4FkS8A==","shasum":"fa936cc21bae1e27f99025025bbe8fd8f942d190","tarball":"https://registry.npmjs.org/node-locksmith/-/node-locksmith-1.0.2.tgz","fileCount":6,"unpackedSize":58236,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCGYH2qF9oKrZPR05t1IF33sw9hYOaMD7mSQcFgn955AgIgB/use6mOtFYQ7jJnePAcFwRGR+rsT4zCqSsNn59C4LQ="}]},"_npmUser":{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"},"directories":{},"maintainers":[{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-locksmith_1.0.2_1702724232229_0.17829316492242753"},"_hasShrinkwrap":false},"1.0.3":{"name":"node-locksmith","version":"1.0.3","description":"node-locksmith ensures that only a single instance of an application can run at once. It uses a lock file to maintain a system-level mutex.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"sai"},"license":"MIT","dependencies":{"ps-node":"^0.1.6"},"keywords":["node","nodejs","node.js","lock","lock manager","singleton","process control","concurrency","single instance","task scheduling","cron","batch jobs","scheduling","task management","maintenance tasks","deployment","development utilities","express","react","ps-node","backend","frontend","fullstack","devops","engines"],"_id":"node-locksmith@1.0.3","gitHead":"6c36e21cf66c9cba42c5af60348b89d74fd9ed0e","_nodeVersion":"20.10.0","_npmVersion":"10.2.5","dist":{"integrity":"sha512-XE4G282ZJQpXX2gZ42+Q8/dMnSlngQ/oxAbglssQOkrbDLM6YHe5yQboYJ/a0L9l37pfD7HurRizsL8H3GPctw==","shasum":"2265e85e00a75f19c15e9606fef17769d9975450","tarball":"https://registry.npmjs.org/node-locksmith/-/node-locksmith-1.0.3.tgz","fileCount":6,"unpackedSize":58697,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDoPmNjAcBruADJqCAb5//2pN7uyweL/kzbfAfxy2IXSgIgEupHGjDOq+iMo/H5OjEJ9+0EETp8NKNl5R8foUvyAD0="}]},"_npmUser":{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"},"directories":{},"maintainers":[{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-locksmith_1.0.3_1702724460231_0.9263543156091087"},"_hasShrinkwrap":false},"1.0.4":{"name":"node-locksmith","version":"1.0.4","description":"node-locksmith ensures that only a single instance of an application can run at once. It uses a lock file to maintain a system-level mutex.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"sai"},"license":"MIT","dependencies":{"ps-node":"^0.1.6"},"keywords":["node","nodejs","node.js","lock","lock manager","singleton","process control","concurrency","single instance","task scheduling","cron","batch jobs","scheduling","task management","maintenance tasks","deployment","development utilities","express","react","ps-node","backend","frontend","fullstack","devops","engines"],"_id":"node-locksmith@1.0.4","gitHead":"f71800c35d7f5d6be0bfbe2c83eb259f6603838c","_nodeVersion":"20.10.0","_npmVersion":"10.2.5","dist":{"integrity":"sha512-n1dJrIaWgDU+3j8zpds54VGPZFM4escP9hi1gh8g1ZDOlgWGie8fs6YykE+1Q/8avdYRYfN/OtBq4dmQKcF5Tg==","shasum":"301d5429e029a225448e2707fb937595e86f0f8c","tarball":"https://registry.npmjs.org/node-locksmith/-/node-locksmith-1.0.4.tgz","fileCount":7,"unpackedSize":73955,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAO3MZ7Zv9nGqES2Jus2N3U6eVkegWLdGugbCpWmSbh0AiAEk16Ymmu1Z6ZR9yS8fTOTmCEJaEYjS2y1zwa0nP3KNg=="}]},"_npmUser":{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"},"directories":{},"maintainers":[{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-locksmith_1.0.4_1702744723314_0.2592649218267602"},"_hasShrinkwrap":false},"1.0.5":{"name":"node-locksmith","version":"1.0.5","description":"node-locksmith ensures that only a single instance of an application can run at once. It uses a lock file to maintain a system-level mutex.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"sai"},"license":"MIT","dependencies":{"ps-node":"^0.1.6"},"keywords":["node","nodejs","node.js","lock","lock manager","singleton","process control","concurrency","single instance","task scheduling","cron","batch jobs","scheduling","task management","maintenance tasks","deployment","development utilities","express","react","ps-node","backend","frontend","fullstack","devops","engines"],"_id":"node-locksmith@1.0.5","gitHead":"fca716feb31613a123d1510539b31042c7f92242","_nodeVersion":"20.10.0","_npmVersion":"10.2.5","dist":{"integrity":"sha512-guhSuZqv1gXXan68AnyY05L6db23hy/RQXQY4L6skUgqafKlFHfynt6I7XfnqVxxc8I9dsD1OM8RrZ/G50SdWA==","shasum":"a31ce986adaca34054867e1d513c4927b07c971c","tarball":"https://registry.npmjs.org/node-locksmith/-/node-locksmith-1.0.5.tgz","fileCount":7,"unpackedSize":73953,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIECvzaZOxCBrIcScMrrPXrrvhw6oy0mQ+q8kEIUE7CHDAiASSqex05QTHgRxn0XR7Rpe9cYKynaxKsMCbLKOI6LPRw=="}]},"_npmUser":{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"},"directories":{},"maintainers":[{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-locksmith_1.0.5_1702744843995_0.4603499053067266"},"_hasShrinkwrap":false},"1.0.6":{"name":"node-locksmith","version":"1.0.6","description":"node-locksmith ensures that only a single instance of an application can run at once. It uses a lock file to maintain a system-level mutex.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"sai"},"license":"MIT","dependencies":{"ps-node":"^0.1.6"},"keywords":["node","nodejs","node.js","lock","lock manager","singleton","process control","concurrency","single instance","task scheduling","cron","batch jobs","scheduling","task management","maintenance tasks","deployment","development utilities","express","react","ps-node","backend","frontend","fullstack","devops","engines"],"_id":"node-locksmith@1.0.6","gitHead":"61cfd16344db0df1543123ddffb414796777228d","_nodeVersion":"20.10.0","_npmVersion":"10.2.5","dist":{"integrity":"sha512-fLTIHhOLN+ewgoovd4Tjy6gkQegp63C13KrySMk/lIuPnQSyu7nsEkZ0NBp6u6NE0NFjvvym0l08fQhXu5ZXhw==","shasum":"9206f8b2ca603f4f40d097f4fecdad910471f3a3","tarball":"https://registry.npmjs.org/node-locksmith/-/node-locksmith-1.0.6.tgz","fileCount":7,"unpackedSize":74077,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAuC781QaxxxYJPlHZy/XGcdFe61TNfyob2OBIaB0vltAiEAsq7jPsPKc1lItd5OFOmXf3fIPG7lCyuTfu06xjMP+uE="}]},"_npmUser":{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"},"directories":{},"maintainers":[{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-locksmith_1.0.6_1702745514165_0.02298792569529451"},"_hasShrinkwrap":false},"1.0.7":{"name":"node-locksmith","version":"1.0.7","description":"node-locksmith ensures that only a single instance of an application can run at once. It uses a lock file to maintain a system-level mutex.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"sai"},"license":"MIT","dependencies":{"ps-node":"^0.1.6"},"keywords":["node","nodejs","node.js","lock","lock manager","singleton","process control","concurrency","single instance","task scheduling","cron","batch jobs","scheduling","task management","maintenance tasks","deployment","development utilities","express","react","ps-node","backend","frontend","fullstack","devops","engines"],"_id":"node-locksmith@1.0.7","gitHead":"6c25cec373afd89b89be7e9f883d77509e74aa96","_nodeVersion":"20.10.0","_npmVersion":"10.2.5","dist":{"integrity":"sha512-/rKcWSn0bCytG61hVd9qZBgk3pyjJcaMzhpwrUIZvT6PpjUtkz1xA+dgVOwrVcCPuv2KQrYe0IB+UzTZQOwaLw==","shasum":"16ee7edcfd116cfce1f9a8261a6e75bfaec2e6eb","tarball":"https://registry.npmjs.org/node-locksmith/-/node-locksmith-1.0.7.tgz","fileCount":7,"unpackedSize":74077,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDXWyw4DabrLzm65BZl05QiQshKVnfDJrnIdNBuUGWYxAIhALBGElwkKyu9D7ynhxYBdTpaQk1XfoGRpEq5ceXnmpqG"}]},"_npmUser":{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"},"directories":{},"maintainers":[{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-locksmith_1.0.7_1702745584052_0.292159678345594"},"_hasShrinkwrap":false},"1.0.8":{"name":"node-locksmith","version":"1.0.8","description":"node-locksmith ensures that only a single instance of an application can run at once. It uses a lock file to maintain a system-level mutex.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"sai"},"license":"MIT","dependencies":{"ps-node":"^0.1.6"},"keywords":["node","nodejs","node.js","lock","lock manager","singleton","process control","concurrency","single instance","task scheduling","cron","batch jobs","scheduling","task management","maintenance tasks","deployment","development utilities","express","react","ps-node","backend","frontend","fullstack","devops","engines"],"_id":"node-locksmith@1.0.8","gitHead":"5513f0a90cce1fddd688908ff09570e6bc12b312","_nodeVersion":"20.10.0","_npmVersion":"10.2.5","dist":{"integrity":"sha512-9QsvPAX9MaVyJJiGuqCrEDYef7rFNn1EkKphR9VinvxxpLyomCADYw0w0g3XiBct1QC7No4dwpvfPTQYMWdrpw==","shasum":"6d2f14e4674eed819feaa5e1619b1359f9a513a5","tarball":"https://registry.npmjs.org/node-locksmith/-/node-locksmith-1.0.8.tgz","fileCount":7,"unpackedSize":74468,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDt8WDCybiuFRDIbbra8+N8NBgm8AX6+hgb4uz9t+VLDwIgaojUfv4Hwhp1lDHV0DF41Dr+s8/MzAuBT8rUC/Cvqrk="}]},"_npmUser":{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"},"directories":{},"maintainers":[{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-locksmith_1.0.8_1702837300460_0.059049118372317855"},"_hasShrinkwrap":false}},"time":{"created":"2023-12-16T10:51:37.936Z","1.0.0":"2023-12-16T10:51:38.138Z","modified":"2023-12-17T18:21:40.802Z","1.0.1":"2023-12-16T10:56:25.351Z","1.0.2":"2023-12-16T10:57:12.477Z","1.0.3":"2023-12-16T11:01:00.481Z","1.0.4":"2023-12-16T16:38:43.515Z","1.0.5":"2023-12-16T16:40:44.231Z","1.0.6":"2023-12-16T16:51:54.411Z","1.0.7":"2023-12-16T16:53:04.225Z","1.0.8":"2023-12-17T18:21:40.628Z"},"maintainers":[{"name":"saivaraprasadreddymedapati","email":"varaprasadreddy9676@gmail.com"}],"description":"node-locksmith ensures that only a single instance of an application can run at once. It uses a lock file to maintain a system-level mutex.","author":{"name":"sai"},"license":"MIT","readme":"<p align=\"center\">\n  <img src=\"https://github.com/varaprasadreddy9676/node-locksmith/blob/main/logo/node-locksmith.png?raw=true\" alt=\"node-locksmith Logo\"/>\n</p>\n\n<h1 align=\"center\">Node Locksmith</h1>\n\n<p align=\"center\">\nLock Your Node.js App Into Single-Instance Mode with Ease!\n</p>\n\n## Table of Contents\n\n1. [Introduction](#-introduction)\n\n   - [Features](#-features)\n\n2. [Installation](#-installation)\n\n3. [Quick Start](#-quick-start)\n\n4. [Configuration](#-configuration)\n\n5. [Exception Handling & Scenarios](#-exception-handling--scenarios)\n\n   - [Reliability](#-reliability)\n   - [Peace of Mind](#-peace-of-mind)\n\n6. [Keep It Up-to-Date](#-keep-it-up-to-date)\n\n7. [Dependencies](#-dependencies)\n\n8. [Troubleshooting](#-troubleshooting)\n\n   - [Lock File Issues](#1-lock-file-issues)\n   - [Permission Errors](#2-permission-errors)\n   - [Concurrent Launch Failures](#3-concurrent-launch-failures)\n   - [Signal Handling](#4-signal-handling)\n   - [Failed to Exit Previous Instance](#5-failed-to-exit-previous-instance)\n   - [Incorrect PID in Lock File](#6-incorrect-pid-in-lock-file)\n   - [Delayed Lock Release on Exit](#7-delayed-lock-release-on-exit)\n   - [Module Import Errors](#8-module-import-errors)\n   - [Unexpected Behavior](#9-unexpected-behavior)\n\n9. [Credits](#-credits)\n\n10. [Author](#-author)\n\n11. [Feedback and Contribution](#-feedback-and-contribution)\n\n12. [License](#-license)\n\n### 🚀 Introduction\n\nHave you ever launched your Node.js app twice by mistake and faced data corruption, performance issues, or other headaches? If so, you need Node Locksmith, the ultimate solution for preventing app duplication disasters.\n\nNode Locksmith is an elegant and straightforward Node.js module that ensures your application runs as a single instance, preventing multiple executions that could lead to data corruption or unexpected behavior. Imagine a world where starting your app twice is impossible – that's the peace of mind Node Locksmith offers!\n\nWhether you're managing batch jobs, cron tasks, or any other Node.js scripts, Node Locksmith keeps them unique so your system stays safe and predictable.\n\n### 🌟 Features\n\n- Effortless Integration: Just a few lines of code to make your app single-instance.\n- Automatic Lock Management: Creates and releases locks without a fuss.\n- Customizable Behaviors: Decide how your app responds to duplicate runs.\n- Cross-Platform Support: Works on both Windows and Unix-like systems.\n- Safe & Secure: Ensures only one instance manages crucial tasks at a time.\n- Lightweight and Mighty: This package weighs in at less than 75KB, ensuring it won't bulk up your project while still delivering robust protection for your Node.js app.\n\n### 💻 Installation\n\nGetting started with Node Locksmith is a snap! Run this command:\n\nnpm install node-locksmith\n\n### 🚀 Quick Start\n\nHere's how simple it is to use Node Locksmith:\n\n```\n// Import and Create a new instance with optional custom settings\n\nconst options = {\n    lockFileName: 'medics_lab_interface_server.lock',\n    killTimeout: 10000,            // Set the timeout for waiting before terminating previous instance (in ms) if its already running.\n    waitForExitTimeout: 20000,    // Set the timeout for waiting for the old process to exit (milliseconds)\n    checkInterval: 500,           // Set the interval for checking the status of the other process (milliseconds)\n    maxRetries: 3,                // Set the maximum number of retries for acquiring the lock\n    defaultAnswer: 'yes'          // Set the default answer for user prompts\n}\n\nconst LockManager = require('node-locksmith');\n\nconst lockManager = new LockManager(options);\n\n// Initializes termination event handlers for graceful application shutdown.\nlockManager.initializeTerminationHandlers();\n\nasync function main() {\n// Check and create a lock before running your app logic\nawait lockManager.checkLock();\nawait lockManager.createLock();\n\n    // Your app logic goes here\n\n}\n\n// Start your app with LockManager in control\nmain();\n```\n\nAnd voilà – you're now running with a robust single-instance lock!\n\n### 🛠 Configuration\n\nNode Locksmith's configuration is both flexible and straightforward:\n\n| Option             | Description                                                                          | Default                    |\n| ------------------ | ------------------------------------------------------------------------------------ | -------------------------- |\n| lockFileName       | Name of your lock file.                                                              | 'app.lock'                 |\n| lockFileDir        | Directory for the lock file.                                                         | \\_\\_dirname (your app dir) |\n| killTimeout        | (Already running process) Time to wait before terminating existing instance (in ms). | 5000                       |\n| waitForExitTimeout | Time to wait for the old instance to exit (in ms).                                   | 10000                      |\n| checkInterval      | Interval to check if the previous instance has exited (in ms).                       | 500                        |\n| maxRetries         | How many times to retry lock acquisition.                                            | 3                          |\n\n### 🛡️ Robust Exception Handling & Real-Life Scenarios\n\n#### Exceptional Reliability in Every Scenario\n\nWe've accounted for an extensive range of scenarios in which your Node.js applications might operate, taking the heavy lifting of error handling off your shoulders. Here are some of the situations we've carefully tested and handled for you:\n\n- Concurrent Launch Attempts: When multiple instances try to start simultaneously, Node Locksmith gracefully ensures only one takes control, while the rest are either terminated or remain uninitiated based on your configuration.\n\n- Orphaned Lock Files: Sometimes applications crash or are terminated abruptly, leaving behind lock files without a running instance. Our module intelligently detects these orphaned locks, removes them, and allows your app to start cleanly.\n\n- Permission Issues: In the event of lock files being created with the wrong permissions, Node Locksmith provides informative error messages and recovery suggestions, making it easier for you to rectify such issues without delving into confusing system errors.\n\n- Process Termination: If an existing instance needs to be closed to allow a new one to start, our module handles SIGTERM signals to shut down the previous instance safely, ensuring data integrity and proper resource cleanup.\n\n- Timeout and Retry Logic: Network file systems and other I/O operations can be unpredictable. Node Locksmith comes with a sophisticated timeout and retry mechanism that stands guard against transient issues, making sure your lock acquisition doesn't fail due to temporary glitches.\n\n#### Beyond Exception Handling: The Peace of Mind Guarantee\n\n- With Node Locksmith, you're not just getting a module but a promise of peace of mind.\n- Once integrated, the module requires no manual intervention. You set it up once, and it runs as intended, every time.\n\n### 📈 Keep It Up-to-Date\n\nNode Locksmith uses semantic versioning. To ensure you have the latest improvements and fixes, keep it updated using npm:\n\nnpm update node-locksmith\n\n### 📦 Dependencies\n\nnode-locksmith utilizes the following third-party libraries:\n\n- ps-node: A process lookup utility for Node.js.\n\nMake sure to check out their documentation for more details on how they work.\n\n### Troubleshooting\n\nEncountering issues can be a hiccup in developing great applications. If you run into any problems with node-locksmith, here are some common issues and their respective solutions.\n\n#### 1. Lock File Issues\n\nIssue: The lock file is not created where expected or is prematurely deleted.\n\nSolution:\n\n- Ensure the lockFileDir directory is writable by the application. If unspecified, process.cwd() is used by default.\n- Check for external processes or scheduled clean-up jobs that might modify or delete files in the lock file directory.\n\n#### 2. Permission Errors\n\nIssue: Encountering permission errors when trying to create, write, or delete the lock file.\n\nSolution:\n\n- Review file system permissions and user ownership for the lock file directory.\n- On Unix-like systems, consider proper permission management or running the process with elevated privileges (sudo) if appropriate.\n\n#### 3. Concurrent Launch Failures\n\nIssue: Multiple instances seem to bypass the lock mechanism, running simultaneously.\n\nSolution:\n\n- Modify checkInterval and maxRetries configuration parameters to give instances more time or attempts to acquire the lock.\n- Double-check that the lock file path is consistent across instances and no instance-specific paths are being used.\n\n#### 4. Signal Handling\n\nIssue: Application doesn’t release the lock after receiving a termination signal.\n\nSolution:\n\n- Ensure lockManager.initializeTerminationHandlers() is called during application setup.\n- Avoid overriding default signal handlers that may prevent node-locksmith from performing clean-up tasks.\n\n#### 5. Failed to Exit Previous Instance\n\nIssue: The application does not terminate the previous instance when requested.\n\nSolution:\n\n- The previous process may require more privileges to be terminated. Run the new instance with adequate permissions, or manually terminate the older one.\n- Investigate whether the operating system’s process management settings are interfering with signal delivery.\n\n#### 6. Incorrect PID in Lock File\n\nIssue: The lock file contains an invalid or old PID, causing conflicts.\n\nSolution:\n\n- Ensure the application closes cleanly to update or remove the lock file.\n- Add additional error handling to detect when the PID in the lock file does not correspond to a running process.\n\n#### 7. Delayed Lock Release on Exit\n\nIssue: The lock file remains after the application exits.\n\nSolution:\n\n- Confirm that clean-up code executes correctly and listen to the correct events for process termination.\n- Look out for asynchronous operations that may delay the process’s exit and subsequently delay the lock release.\n\n#### 8. Module Import Errors\n\nIssue: TypeScript definitions are missing or not found, resulting in import errors.\n\nSolution:\n\n- If using TypeScript, ensure you’ve included type declarations for node-locksmith, or create a .d.ts file declaring module typings.\n- Check that the module is installed correctly under node_modules and is not corrupted.\n\n#### 9. Unexpected Behavior\n\nIssue: Experiencing erratic behavior or errors that are not covered by the guide.\n\nSolution:\n\n- Check the Node.js version for compatibility issues; update Node.js or node-locksmith if necessary.\n- Review the project’s GitHub issues for similar problems, or report a new issue with detailed information about the Node.js version, operating system, stack trace, and steps to reproduce the error.\n\nFor issues beyond these common scenarios, please open an issue on the node-locksmith GitHub repository with as much detail as possible. Our community is here to help!\n\n### 📜 Credits\n\nThis module stands as a testament to the collective knowledge and inspiration drawn from significant figures who have played pivotal roles in shaping my professional journey. Gratitude is extended to:\n\n- My CEO: For visionary leadership and unwavering support that has been instrumental in fostering my growth. His profound insights into the internals of software engineering, emphasis on principles of engineering like modularity, scalability and robustness, and the embodiment of a forward-thinking vision have been invaluable. The teachings and experiences derived from his mentorship have left an great mark on this me and significantly influenced my approach to software development.\n\n- The Management Team & Colleagues: Providing invaluable guidance, encouragement, and the freedom to innovate, this team has been crucial to the development of this module.\n\n- The Broader Open-Source Community: Acknowledgment to the tireless efforts of the open-source community, whose contributions to the Node.js ecosystem laid the foundation upon which this module stands.\n\nI express deep gratitude for the collective wisdom and experiences shared by each individual mentioned above. Their influence has not only shaped this project but has also profoundly impacted my understanding of software development.\n\n### ✍️ Author\n\nSai varaprasad (https://github.com/varaprasadreddy9676) - Initial work - A passionate software engineer who enjoys turning complex problems into simple, beautiful, and intuitive solutions. When I’m not coding, evangelizing best practices, you can find me immersed in reading, exploring new technology.\n\n### 📣 Feedback and Contribution\n\nYour feedback and contributions are welcome! Please submit issues or pull requests on our GitHub repository.\nhttps://github.com/varaprasadreddy9676/node-locksmith\n\nInterested in contributing? We welcome pull requests! Let's make Node Locksmith better, together.\n\n### 📜 License\n\nNode Locksmith is MIT licensed, so feel free to use it in your projects.\n\n—\n\nGive Node Locksmith a try, and say goodbye to running multiple instances by accident!\n","readmeFilename":"README.md","keywords":["node","nodejs","node.js","lock","lock manager","singleton","process control","concurrency","single instance","task scheduling","cron","batch jobs","scheduling","task management","maintenance tasks","deployment","development utilities","express","react","ps-node","backend","frontend","fullstack","devops","engines"]}