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

daemontools

v0.0.0

Published

Control daemontools (svc, svstat) with Node

Downloads

18

Readme

node-daemontools

Control daemontools (svc, svstat) with Node

Installation

npm install daemontools

Example

var daemontools = require('daemontools');

// check nginx status
daemontools.svstat('/service/nginx', function(err, stats) {
  if (err)
    throw err; // permission denied, service not found, etc.

  console.dir(stats);
});

// restart apache
daemontools.restart('/service/apache', function(err) {
  if (err)
    throw err; // permission denied, service not found, etc.

  // => service restarted
});

This example will show the current status of the nginx daemon, as well as restart the apache service.

Usage

daemontools.svstat(file, cb)

A function that mimics svstat(1) by reading a daemons status file and extracting meaningful data.

  • file - a service file
  • cb - a function in the form of function(err, stats)

example:

daemontools.svstat('/service/nginx', function(err, stats) {
  console.dir(stats);
})

output

{
  "name": "nginx",
  "path": "/service/nginx",
  "pid": 3985,
  "up": true,
  "paused": false,
  "want": "up",
  "changed": "2014-07-26T06:09:42.000Z",
  "elapsed": 5
}

daemontools.svc(file, data, cb)

mimics svc(1) by writing to a daemons control file

  • file - a service file
  • data - a string to pass to the control file, like d for down, u for up, etc.
  • cb - a function in the form of function(err) (passed to fs.appendFile)

example:

daemontools.svc('/service/nginx', 'dx', function(err) {
  // => nginx is now disabled and exited
})

convenience functions

The following functions have been defined to call daemontools.svc with predefined arguments for convenience.

All functions take a file as the first argument and a callback as the second. The names were modeled after the arguments supported by the svc(1) program - http://cr.yp.to/daemontools/svc.html.

  • daemontools.up(file, cb)
  • daemontools.down(file, cb)
  • daemontools.once(file, cb)
  • daemontools.term(file, cb)
  • daemontools.kill(file, cb)
  • daemontools.exit(file, cb)
  • daemontools.pause(file, cb)
  • daemontools.cont(file, cb)
  • daemontools.hup(file, cb)
  • daemontools.int(file, cb)
  • daemontools.alarm(file, cb)

And the following aliases have been defined

  • daemontools.start(file, cb) - same as up
  • daemontools.stop(file, cb) - same as down
  • daemontools.restart(file, cb) - same as term

License

LICENSE - "MIT License" Copyright (c) 2013-2014 Voxer LLC. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.