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

easy-pid-file

v1.0.7

Published

easy file.pid managment for node.js process

Downloads

10

Readme

easy-pid-file

[TOC]

Intro

Easy management of the file.pid (simple file holding the PID number of the node process), this can be useful when the process need to be always alive on the server machine and so on ....

Chose the path to store te file (right privilege for that path if is a system folder) ** eg. /var/mynodeprocess.pid ** , and with one line of code you are ok !

If the path you set in won't be valid an error ENOENT or EACCES will be raise !

HOW it works

Here i'll show how use the package, with a short version, you get only the .pid file on the path, or with the initialization of the var that can be use to check the file's write operation :

    // create the .pid file in the project folder
    require('./easy-pid-file')('my-process-pid.pid');

    // instantiate and use the variable
    var pidfile = require('./easy-pid-file.js')('~/project-x/my-process-pid.pid');

    // check
    if(pidfile.getState()){
      // true
    }else{
      // false
    }

If you want to save file.pid in system's folder like '/run/..' '/var/..' and so on, be sure that your Node.js process granted the right privilege (otherwise check return false and file.pid fails).

methods

You get only two methods you can use the getPath() and the getState() :

    var pidfile = require('./easy-pid-file.js')('myfile.pid');

    // get you the path  you have inserted
    pidfile.getPath();  

    // get you the status true(CREATED)
    pidfile.getState();  

ENOENT & EACCES

If a false value is returned an exception is raised, the exceptions catch in the False value returned are the ENOENT and the EACCES.

Exists / NOT

The package do NOT create new folder, if the path does NOT exists, a Boolean value False is returned, and the file.pid won't be create. The simplicity of this package give at you the responsibility to pass a valid path in the package call.

That's it, that's all !!