Skip to content

munogu/node-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Cross-platform service management tool for Node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published