2018-08-02 15:31:05 +02:00
|
|
|
# @pushrocks/smartspawn
|
2016-09-28 14:22:23 +02:00
|
|
|
smart subprocess handling
|
|
|
|
|
2019-04-08 15:13:47 +02:00
|
|
|
## Availabililty and Links
|
|
|
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartspawn)
|
|
|
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartspawn)
|
|
|
|
* [github.com (source mirror)](https://github.com/pushrocks/smartspawn)
|
|
|
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartspawn/)
|
2016-09-28 14:22:23 +02:00
|
|
|
|
|
|
|
## Status for master
|
2019-04-08 15:13:47 +02:00
|
|
|
[](https://gitlab.com/pushrocks/smartspawn/commits/master)
|
|
|
|
[](https://gitlab.com/pushrocks/smartspawn/commits/master)
|
|
|
|
[](https://www.npmjs.com/package/@pushrocks/smartspawn)
|
|
|
|
[](https://snyk.io/test/npm/@pushrocks/smartspawn)
|
|
|
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
|
|
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
|
|
|
[](https://prettier.io/)
|
2016-09-28 14:22:23 +02:00
|
|
|
|
2017-03-03 20:55:54 +01:00
|
|
|
## Usage
|
2018-08-02 15:31:05 +02:00
|
|
|
|
2017-03-03 20:55:54 +01:00
|
|
|
Use TypeScript for best in class instellisense.
|
|
|
|
|
|
|
|
### Understand the Purpose
|
2018-08-02 15:31:05 +02:00
|
|
|
|
2016-09-28 14:22:23 +02:00
|
|
|
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.
|
|
|
|
|
2017-03-03 20:55:54 +01:00
|
|
|
### How To
|
2016-09-28 14:22:23 +02:00
|
|
|
|
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
|
2018-08-02 15:31:05 +02:00
|
|
|
import * as smartspawn from 'smartspawn';
|
|
|
|
smartspawn.setBasePathArg(__dirname); // if you want to avoid typings out full paths every time
|
2016-09-28 14:22:23 +02:00
|
|
|
|
2018-08-02 15:31:05 +02:00
|
|
|
let myThread = new smartspawn.Thread('worker');
|
2017-01-29 23:46:09 +01:00
|
|
|
myThread.send('someMessageOrObject').then(messageResponse => {
|
2018-08-02 15:31:05 +02:00
|
|
|
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:23:47 +02:00
|
|
|
```
|
2017-03-03 20:55:54 +01:00
|
|
|
|
2019-04-08 15:13:47 +02:00
|
|
|
For further information read the linked docs at the top of this readme.
|
2017-03-03 20:55:54 +01:00
|
|
|
|
|
|
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
2019-08-22 00:32:09 +02:00
|
|
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
2017-03-03 20:55:54 +01:00
|
|
|
|
2019-08-22 00:32:09 +02:00
|
|
|
[](https://maintainedby.lossless.com)
|