README
# WindRibbon P2P Process Chain (XP2PProcessChain)
Introduction
This module is the peer-side process manager of WindRibbon P2P system. This module maintains a set of processes, you can add a process to this set dynamically. If one of these processes exits, all other processes (including this module) will exit also.
Requirements
Here is the software requirement:
Package | Version |
---|---|
NodeJS | >= 8.7.0 |
Installation
Type following command to install this package.
npm install -g xp2pprocesschain
Then you can use following command to start the system.
xp2pprocesschain -c "[Configuration Path]"
Configuration
Here is the template of configurations:
{
"bind": {
"address": "127.0.0.1", // Bind address of HTTP API.
"port": 0 // Bind port of HTTP API.
},
"timeout": 120000, // (Optional) Timeout of HTTP connections (default: 2min).
"bootstrap": { // (Optional) Bootstrap script.
"enable": true, // Whether the bootstrap script was enabled.
"cwd": "examples/01-basic", // (Optional) The working directory of the bootstrap script.
"command": "./always-loop.sh", // The command line of the bootstrap script.
"arguments": [
... // The command arguments of the bootstrap script.
],
"notifier": "start: always-loop" // The notify message after running the bootstrap script.
},
"ipc": {
"enable": false // Whether the IPC was enabled.
}
}
See "examples" directory for more details.
HTTP API
This module provides a set of external API by using HTTP.
(POST) /chain
This API was used to add a process to the processes set dynamically. The request body must be written in JSON format and the "Content-Type" header must be "application/json".
Template of the request body:
{
"cwd": "examples/02-notifier", // The working directory of the new program.
"command": "./always-loop.sh", // The command line of the new program.
"notifier": "start: always-loop" // The notify message after executed the new program.
}
Once succeed, the API server will reply:
OK
(POST) /notify
To send a notify message, use this API.
Template of the request body:
{
"notifier": "start: always-loop" // The notify message after executed the new program.
}
Once succeed, the API server will reply:
OK
IPC
This module provides IPC function to communicate with the parent process who creates this module process. To know how IPC work, see "examples/02-notifier".