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

linux-systemd

v0.0.1

Published

Systemd wrapper

Downloads

59

Readme

linux-systemd

Systemd wrapper

Available functions

systemd

Returns a Systemd object.

var systemd = require("linux-systemd").systemd;

var sysd = systemd();

listNames

Retrieves a list containing the services name.

var listNames = require("linux-systemd").listNames;

listNames()
  .then(names => {
    console.log(names);
  })
  .catch(e => {
    console.error(e);
  });

listNames((error, names) => {
  if (error) {
    console.error(error);
  } else {
    console.log(names);
  }
});

list

Retrieves a list containing the services basic informations.

  • name
  • description
  • loadState
  • activeState
  • subState
  • unitFileState
var list = require("linux-systemd").list;

list()
  .then(informations => {
    console.log(informations);
  })
  .catch(e => {
    console.error(e);
  });

list((error, informations) => {
  if (error) {
    console.error(error);
  } else {
    console.log(informations);
  }
});

exists

Checks if a service name exists.

var exists = require("linux-systemd").exists;

exists("sshd")
  .then(exists => {
    if (exists) {
      console.log("The service sshd exists");
    } else {
      console.log("The service sshd doesn't exists");
    }
  })
  .catch(e => {
    console.error(e);
  });

exists("sshd", (error, exists) => {
  if (error) {
    console.error(e);
  } else {
    if (exists) {
      console.log("The service sshd exists");
    } else {
      console.log("The service sshd doesn't exists");
    }
  }
});

basicInformations

Retrieves the basic informations of a service.

var basicInformations = require("linux-systemd").basicInformations;

basicInformations("sshd")
  .then(informations => {
    console.log(informations);
  })
  .catch(e => {
    console.error(e);
  });

basicInformations("sshd", (error, informations) => {
  if (error) {
    console.error(e);
  } else {
    console.log(informations);
  }
});

detailedInformations

Retrieves the detailed informations of a service.

var detailedInformations = require("linux-systemd").detailedInformations;

detailedInformations("sshd")
  .then(informations => {
    console.log(informations);
  })
  .catch(e => {
    console.error(e);
  });

detailedInformations("sshd", (error, informations) => {
  if (error) {
    console.error(e);
  } else {
    console.log(informations);
  }
});

loadState

Retrieves the loadState of a service.

var loadState = require("linux-systemd").loadState;

loadState("sshd")
  .then(state => {
    console.log(state);
  })
  .catch(e => {
    console.error(e);
  });

loadState("sshd", (error, state) => {
  if (error) {
    console.error(error);
  } else {
    console.log(state);
  }
});

activeState

Retrieves the activeState of a service.

var activeState = require("linux-systemd").activeState;

activeState("sshd")
  .then(state => {
    console.log(state);
  })
  .catch(e => {
    console.error(e);
  });

activeState("sshd", (error, state) => {
  if (error) {
    console.error(error);
  } else {
    console.log(state);
  }
});

unitFileState

Retrieves the unitFileState of a service.

var unitFileState = require("linux-systemd").unitFileState;

unitFileState("sshd")
  .then(state => {
    console.log(state);
  })
  .catch(e => {
    console.error(e);
  });

unitFileState("sshd", (error, state) => {
  if (error) {
    console.error(error);
  } else {
    console.log(state);
  }
});

start

Starts a service.

var start = require("linux-systemd").start;

start("sshd")
  .then(() => {
    console.log("The service sshd has been started");
  })
  .catch(e => {
    console.error("The service sshd hasn't been started:\n" + e);
  });

start("sshd", error => {
  if (error) {
    console.error("The service sshd hasn't been started:\n" + error);
  } else {
    console.log("The service sshd has been started");
  }
});

stop

Stops a service.

var stop = require("linux-systemd").stop;

stop("sshd")
  .then(() => {
    console.log("The service sshd has been stoped");
  })
  .catch(e => {
    console.error("The service sshd hasn't been stoped:\n" + e);
  });

stop("sshd", error => {
  if (error) {
    console.error("The service sshd hasn't been stoped:\n" + error);
  } else {
    console.log("The service sshd has been stoped");
  }
});

restart

Restarts a service.

var restart = require("linux-systemd").restart;

restart("sshd")
  .then(() => {
    console.log("The service sshd has been restarted");
  })
  .catch(e => {
    console.error("The service sshd hasn't been restarted:\n" + e);
  });

restart("sshd", error => {
  if (error) {
    console.error("The service sshd hasn't been restarted:\n" + error);
  } else {
    console.log("The service sshd has been restarted");
  }
});

enable

Enables a service.

var enable = require("linux-systemd").enable;

enable("sshd")
  .then(() => {
    console.log("The service sshd has been enabled");
  })
  .catch(e => {
    console.error("The service sshd hasn't been enabled:\n" + e);
  });

enable("sshd", error => {
  if (error) {
    console.error("The service sshd hasn't been enabled:\n" + error);
  } else {
    console.log("The service sshd has been enabled");
  }
});

disable

Disables a service.

var disable = require("linux-systemd").disable;

disable("sshd")
  .then(() => {
    console.log("The service sshd has been disabled");
  })
  .catch(e => {
    console.error("The service sshd hasn't been disabled:\n" + e);
  });

disable("sshd", error => {
  if (error) {
    console.error("The service sshd hasn't been disabled:\n" + error);
  } else {
    console.log("The service sshd has been disabled");
  }
});

mask

Masks a service.

var mask = require("linux-systemd").mask;

mask("sshd")
  .then(() => {
    console.log("The service sshd has been masked");
  })
  .catch(e => {
    console.error("The service sshd hasn't been masked:\n" + e);
  });

mask("sshd", error => {
  if (error) {
    console.error("The service sshd hasn't been masked:\n" + error);
  } else {
    console.log("The service sshd has been masked");
  }
});

unmask

Unmasks a service.

var unmask = require("linux-systemd").unmask;

unmask("sshd")
  .then(() => {
    console.log("The service sshd has been unmasked");
  })
  .catch(e => {
    console.error("The service sshd hasn't been unmasked:\n" + e);
  });

unmask("sshd", error => {
  if (error) {
    console.error("The service sshd hasn't been unmasked:\n" + error);
  } else {
    console.log("The service sshd has been unmasked");
  }
});