Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aaronhuggins/managed-daemon

A wrapper for spawning child processes as managed daemons in Node.
https://github.com/aaronhuggins/managed-daemon

Last synced: 9 days ago
JSON representation

A wrapper for spawning child processes as managed daemons in Node.

Awesome Lists containing this project

README

        

# Managed Service Daemon

A wrapper for spawning child processes as managed daemons in Node, with typescript definitions included.

## Usage

Install via [NPM](https://www.npmjs.com/package/managed-service-daemon) and require in your project.

```js
const gulp = require('gulp')
const shell = require('gulp-shell')
const { Service } = require('managed-service-daemon')
const workingDir = './.azurite'
const azuriteBlob = new Service({
name: 'azuriteBlob',
command: 'node',
args: [path.normalize('./node_modules/azurite/dist/src/blob/main'), '-s', '-l', workingDir],
startWait: 500,
onStart: () => fs.mkdirSync(workingDir),
onStop: () => fs.rmdirSync(workingDir, { recursive: true })
})

exports.mocha = async function mocha () {
return shell.task(['mocha'], { ignoreErrors: true })()
}

exports.test = gulp.series(azuriteBlob.start, exports.mocha, azuriteBlob.stop)
```

The Service options also accept all non-overlapping `child_process.spawn` options; overlapping options would include `stdio`, for example.

Aditional options specific to the Service class can be viewed in the [TypeScript code](./src/Interfaces.ts).