← 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

FieldTypeRequiredDefaultDescription
scriptstringyesScript path to run
argsstring[]noArguments to pass to the script
cwdstringnoWorking directory
envobjectnoEnvironment variables
readyobjectnoReady pattern - wait for this in stdout before returning

Output

FieldTypeRequiredDefaultDescription
processIdstringyesThe id of the process: node.kill and node.status take it
pidnumberyesThe 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": {}
  }
}