service-manager

A service manager for linux(and windows SOON(TM)) scripts

npm install service-manager
4 downloads in the last week
17 downloads in the last month

node-service-manager

Build Status

A Linux(and soon Windows) Service Manager for node.js

How to use

Services can be managed in two ways

  • Via node.js code using the node-service class
  • Via servicemgr that comes with the package(when using npm install -g)

Creating a new service via node.js

var service = require('service-manager');
var svc = new service.Service({
  name: "test", // sets the name of the service(will be used in service *name* start in Linux for example)
  displayname: "Test Server", // sets a displayname for the service, defaults to *name*
  description: "This is a test server!", // sets a description for the service
  run: "node", // sets what file to run
  args: ["/root/test-server.js"], // sets file arguments
  output: true, // sets wheter log to console
  log: false // sets wheter linux services should log stdout and stderr
});

install(callback) or installSync()

Requires atleast name and run in settings


svc.install(function(isInstalled) {
});

if(svc.installSync()) {
}

uninstall(callback) or uninstallSync()

Requires atleast name in settings


svc.uninstall(function(isUninstalled) {
});

if(svc.uninstallSync() {
}

start(), stop() and restart()

TODO

Via the command-line

servicemgr install test node /root/test-server.js

servicemgr uninstall test
npm loves you