← All procedures
node.spawn
Spawn a long-running Node.js process
CLI- Package
- @procedures/node · README
- Path
["node","spawn"]- CLI
mark node spawn --script <string>- As data
{"$proc":["node","spawn"],"input":{}}
Use it
In TypeScript
import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/node"; // registers its procedures
const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["node","spawn"], { script: "<script>" });
console.log(JSON.stringify(result));From the command line
$ mark node spawn --script <string>
As data, in a program
{ "$proc": ["node", "spawn"], "input": { "script": "<script>" } }Input
| Field | Type | Required | Default | Description |
|---|
script | string | yes | | Script path to run |
args | string[] | no | | Arguments to pass to the script |
cwd | string | no | | Working directory |
env | object | no | | Environment variables |
ready | object | no | | Ready pattern - wait for this in stdout before returning |
Output
| Field | Type | Required | Default | Description |
|---|
processId | string | yes | | The id of the process: node.kill and node.status take it |
pid | number | yes | | The process id of the operating system |
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"script": {
"type": "string",
"description": "Script path to run"
},
"args": {
"description": "Arguments to pass to the script",
"type": "array",
"items": {
"type": "string"
}
},
"cwd": {
"description": "Working directory",
"type": "string"
},
"env": {
"description": "Environment variables",
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"type": "string"
}
},
"ready": {
"description": "Ready pattern - wait for this in stdout before returning",
"type": "object",
"properties": {
"pattern": {
"type": "string"
},
"timeout": {
"type": "number"
}
},
"required": [
"pattern"
]
}
},
"required": [
"script"
]
},
"output": {
"type": "object",
"properties": {
"processId": {
"type": "string",
"description": "The id of the process: node.kill and node.status take it"
},
"pid": {
"type": "number",
"description": "The process id of the operating system"
}
},
"required": [
"processId",
"pid"
],
"additionalProperties": {}
}
}