
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
child-service
Advanced tools
Start services as child-process, wait until they are ready and stop them.
Start services as child-process, wait until they are ready and stop them.
npm install child-service
Let's assume, we have a service that does not detach, but it is not ready immediately after start. We want to start this service call some endpoints and stop it again (for example in tests). Assume that our service is implemented in service.js (for portability, we use a Node.js program in this example, but I actually wrote this tool for use with chisel.
We can now do the following.
const { ChildService } = require("child-service");
const got = require("got");
// We call nodejs in this example, but in reality, it
// is probably some binary executable.
const childService = new ChildService({
command: process.execPath, // you can also use a promise here
args: ["service.js"], // you can also use a promise here
readyRegex: /Listening on port 3000/,
spawnOptions: {
cwd: __dirname
}
});
(async function () {
await childService.start();
console.log("Started!");
const response = await got("http://127.0.0.1:3000");
console.log(response.body);
await childService.stop();
console.log("Stopped!");
})();
This will start the service, wait until the stdout matches pattern, then call an endpoint and stop it again. The output of this program is:
Started!
hello
Stopped!
The package also makes sure that processes are stopped when the parent-process dies unexpectedly. It takes into account quitting by process.exit() as well as SIGTERM, SIGINT and SIGKILL.
The class for starting and stopping services.
Kind: global class
Access: public
Promise.<void>Promise.<void>Create a new child-service
| Param | Type | Description |
|---|---|---|
| userOptions | object | parameters |
| userOptions.command | string | Promise.<string> | the command to execute |
| [userOptions.args] | Array.<string> | Promise.<Array.<string>> | arguments to the command |
| [userOptions.readyRegex] | RegExp | process is assumed to be ready, when this regex matches the output. |
| [userOptions.outputLimit] | number | only look for readyRegex in the first "outputLimit" number of bytes of the output. |
| [userOptions.spawnOptions] | object | options to pass to child_process.spawn |
| [userOptions.timeoutAfterSignal] | number | (default: 1000) how long (in milliseconds) to wait after stopping the child with SIGTERM, before using SIGKILL and after that before giving up. |
| [userOptions.listenOnStderr] | boolean | (default: false) whether to wait for "readyRegex" on stderr of the child-process instead of stdout |
Promise.<void>Starts the service.
Kind: instance method of ChildService
Returns: Promise.<void> - resolves when the "readyRegex" has been found.
Promise.<void>Stop the service.
Kind: instance method of ChildService
Returns: Promise.<void> - resolves, when the executable has exited.
child-service is published under the MIT-license.
See LICENSE.md for details.
For release notes, see CHANGELOG.md
See CONTRIBUTING.md.
FAQs
Start services as child-process, wait until they are ready and stop them.
We found that child-service demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.