Cross-platform service management tool for Node.js
It uses launchd on darwin
, systemd on linux
and nssm.exe for win32
.
- Administrative privileges
- Node.js >= 6.0
$ npm install @munogu/service
// 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')
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()
console.log('Service installed & started')
service.uninstall()
console.log('Service is disabled & uninstalled')
Returns service status. true
if running, false
if not.
if (service.status()) {
console.log('service is running')
} else {
console.log('service is NOT running')
}
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.