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

@mh-cbon/systemd-simple-api

v2.1.5

Published

Systemd simple api to manage services

Downloads

12

Readme

systemd-simple-api

Simple api for node to interface with systemd bin.

Install

npm i @mh-cbon/systemd-simple-api --save

Usage

var SystemdSimpleApi = require('@mh-cbon/systemd-simple-api');
var sds = new SystemdSimpleApi(/* version */);

// enable sudo
sds.enableElevation(''); // will now read the password from yasudo env variable
sds.enableElevation('the password'); // will now use 'the password'
sds.enableElevation(false); // will disable use of sudo

// systemctl --user -t service --all
sds.list(opts={user: true, t: 'service', all: true}, function (err, items) {
  console.log(items);
})

// systemctl -t timers
sds.list(opts={t: 'timers'}, function (err, items) {
  console.log(items);
})

// systemctl list-unit-files --user
sds.listUnitFiles(opts={user: true}, function (err, items) {
  console.log(items);
})

// systemctl show serviceId --user
sds.describe('serviceId', opts={user: true}, function (err, info) {
  console.log(info);
})

// systemctl start serviceId --user
sds.start('serviceId', opts={user: true}, function (err) {
  console.log(err);
})

// systemctl stop serviceId --user
sds.stop('serviceId', opts={user: true}, function (err) {
  console.log(err);
})

// systemctl reload serviceId --user
sds.reload(opts={user: true}, function (err) {
  console.log(err);
})

// systemctl reload-or-restart serviceId --user
sds.reloadOrRestart(opts={user: true}, function (err) {
  console.log(err);
})

// systemctl daemon-reload
sds.refresh(function () {
  console.log('systemd is refreshed')
})

Install a service

// per user
var service = {
  install:{},
  unit: {
    Description: "your service"
  },
  service: {
    ExecStart: '/bin/sh ...'
  }
}
sds.install({user: true, id: 'fake', properties: service}, done)

// system wide
var service = {
  install:{},
  unit: {
    Description: "your service"
  },
  service: {
    ExecStart: '/bin/sh ...'
  }
}
sds.install({user: !true, id: 'fake', properties: service}, done)


// later...
sds.uninstall({user: !true, id: 'fake', properties: service}, done)

Run the tests

  • install vagrant
  • run npm run test-fedora

Read more

  • https://coreos.com/os/docs/latest/using-environment-variables-in-systemd-units.html
  • https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files
  • https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
  • https://www.freedesktop.org/software/systemd/man/systemd.unit.html#id-1.7.4
  • https://www.freedesktop.org/software/systemd/man/systemd.service.html#
  • https://www.freedesktop.org/software/systemd/man/systemd.exec.html#
  • https://www.freedesktop.org/software/systemd/man/systemd.kill.html#
  • https://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet