Skip to content

Latest commit

 

History

History
98 lines (72 loc) · 2.26 KB

README.md

File metadata and controls

98 lines (72 loc) · 2.26 KB

Node service

Cross-platform service management tool for Node.js

It uses launchd on darwin, systemd on linux and nssm.exe for win32.

Standard - JavaScript Style Guide

Requirements

  • Administrative privileges
  • Node.js >= 6.0

Installation

$ npm install @munogu/service

Quick Start

// module dependencies
const Service = require('@munogu/service')

// initialize service
let service = new Service({
  name: 'my-service',
  description: 'My awesome service',
  argv: ['node', 'index.js']
})

// install service
service.install()
console.log('service installed')

API

Service(options = object)

new Service({
  // machine readable alphanumeric service name
  name: 'my-service',
  // service description
  description: 'My awesome service',
  // service entry argv
  argv: ['node', 'index.js']
})
console.log('Service installed & started')

Service.install() - void

service.install()
console.log('Service installed & started')

Service.uninstall() - void

service.uninstall()
console.log('Service is disabled & uninstalled')

Service.status() - Boolean

Returns service status. true if running, false if not.

if (service.status()) {
  console.log('service is running')
} else {
  console.log('service is NOT running')
}

Debugging

Node service along with many of the libraries it's built with support the DEBUG environment variable from debug which provides simple conditional logging.

For example to see all service specific debugging information just pass DEBUG=service* and upon boot you'll see the list of middleware used, among other things.