2016-09-28 14:22:23 +02:00
|
|
|
# smartipc
|
|
|
|
smart subprocess handling
|
|
|
|
|
|
|
|
## Availabililty
|
|
|
|
[](https://www.npmjs.com/package/smartipc)
|
|
|
|
[](https://gitlab.com/pushrocks/smartipc)
|
|
|
|
[](https://github.com/pushrocks/smartipc)
|
|
|
|
[](https://pushrocks.gitlab.io/smartipc/)
|
|
|
|
|
|
|
|
## Status for master
|
|
|
|
[](https://gitlab.com/pushrocks/smartipc/commits/master)
|
|
|
|
[](https://gitlab.com/pushrocks/smartipc/commits/master)
|
|
|
|
[](https://david-dm.org/pushrocks/smartipc)
|
|
|
|
[](https://www.bithound.io/github/pushrocks/smartipc/master/dependencies/npm)
|
|
|
|
[](https://www.bithound.io/github/pushrocks/smartipc)
|
|
|
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
|
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
|
|
[](http://standardjs.com/)
|
|
|
|
|
|
|
|
## The purpose
|
|
|
|
smartipc makes it easy to spawn tasks into subprocesses without loosing control over what those processes do.
|
|
|
|
You can transparently call functions and expect returned data using promises.
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2017-01-29 23:46:09 +01:00
|
|
|
**Master.ts:**
|
2016-09-28 14:22:23 +02:00
|
|
|
|
2017-01-29 23:46:09 +01:00
|
|
|
```javascript
|
|
|
|
import * as smartipc from 'smartipc'
|
|
|
|
smartipc.setBasePathArg(__dirname) // if you want to avoid typings out full paths every time
|
2016-09-28 14:22:23 +02:00
|
|
|
|
2017-01-29 23:46:09 +01:00
|
|
|
let myThread = new smartipc.Thread('worker')
|
|
|
|
myThread.send('someMessageOrObject').then(messageResponse => {
|
|
|
|
console.log(messageResponse)
|
2016-09-28 14:22:23 +02:00
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2017-01-29 23:46:09 +01:00
|
|
|
**worker.ts**
|
2016-09-28 14:22:23 +02:00
|
|
|
|
2017-01-29 23:46:09 +01:00
|
|
|
```javascript
|
2016-09-28 14:22:23 +02:00
|
|
|
|
2016-09-28 14:23:47 +02:00
|
|
|
```
|
|
|
|
[](https://push.rocks)
|