service-manager
Version:
A service manager for linux(and windows SOON(TM)) scripts
61 lines (43 loc) • 1.56 kB
Plain Text
[](https://travis-ci.org/ArmedGuy/node-service-manager)
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
```node
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
});
```
Requires atleast *name* and *run* in settings
```node
svc.install(function(isInstalled) {
});
if(svc.installSync()) {
}
```
Requires atleast *name* in settings
```node
svc.uninstall(function(isUninstalled) {
});
if(svc.uninstallSync() {
}
```
TODO
```bash
servicemgr install test node /root/test-server.js
servicemgr uninstall test
```