{"id":15680551,"url":"https://github.com/doowb/background-process","last_synced_at":"2025-10-08T20:18:12.730Z","repository":{"id":65990614,"uuid":"65845063","full_name":"doowb/background-process","owner":"doowb","description":"Run a process in the background, disconnected from the main process.","archived":false,"fork":false,"pushed_at":"2017-05-08T22:03:58.000Z","size":17,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-08T20:18:11.069Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doowb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-16T18:44:47.000Z","updated_at":"2021-04-23T03:18:36.000Z","dependencies_parsed_at":"2023-02-28T11:15:26.331Z","dependency_job_id":null,"html_url":"https://github.com/doowb/background-process","commit_stats":{"total_commits":19,"total_committers":3,"mean_commits":6.333333333333333,"dds":0.1578947368421053,"last_synced_commit":"0eb893b945ac4967feae87c069bcbd998a815a9d"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/doowb/background-process","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fbackground-process","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fbackground-process/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fbackground-process/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fbackground-process/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doowb","download_url":"https://codeload.github.com/doowb/background-process/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fbackground-process/sbom","scorecard":{"id":352313,"data":{"date":"2025-08-11","repo":{"name":"github.com/doowb/background-process","commit":"0eb893b945ac4967feae87c069bcbd998a815a9d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 1/17 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 4 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T08:38:57.723Z","repository_id":65990614,"created_at":"2025-08-18T08:38:57.723Z","updated_at":"2025-08-18T08:38:57.723Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000663,"owners_count":26082817,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T16:42:47.147Z","updated_at":"2025-10-08T20:18:12.684Z","avatar_url":"https://github.com/doowb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# background-process [![NPM version](https://img.shields.io/npm/v/background-process.svg?style=flat)](https://www.npmjs.com/package/background-process) [![NPM monthly downloads](https://img.shields.io/npm/dm/background-process.svg?style=flat)](https://npmjs.org/package/background-process)  [![NPM total downloads](https://img.shields.io/npm/dt/background-process.svg?style=flat)](https://npmjs.org/package/background-process) [![Linux Build Status](https://img.shields.io/travis/doowb/background-process.svg?style=flat\u0026label=Travis)](https://travis-ci.org/doowb/background-process)\n\n\u003e Run a process in the background, disconnected from the main process.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save background-process\n```\n\nInstall with [yarn](https://yarnpkg.com):\n\n```sh\n$ yarn add background-process\n```\n\n## Usage\n\nThe api has two methods that can be used. The first method is [.start](#start) and should be used in an application that runs the background script. This application is the [runner](#runner).\n\nThe second method is [.ready](#ready) and should be used inside background scripts to know when they should start executing. The runner will use `process.send` to send an `options` object to the background script. The `options` object is passed as the second argument to the callback function passed to [.ready](#ready).\n\nThe [.ready](#ready) method is not required to be used in the background script since the runner will \"fire and forget\" when it sends the `options` object. It's recommended to use [.ready](#ready) since it'll be easier to configure your background scripts.\n\n### Runner\n\nThis is an example of running a background script called `my-script.js` and passing an `options` object.\n\n```js\nvar background = require('background-process');\n\n// start a background script and pass options to the script\nvar options = { foo: 'bar' };\nbackground.start('my-script.js', options);\n```\n\n### Script\n\nThis is an example of a background script called `my-script.js` that was passed an `options` object.\n\n```js\nvar background = require('background-process');\n\n// wait for the options to be sent from the runner\nbackground.ready(function(err, options) {\n  if (err) return console.error(err);\n  console.log(options);\n});\n```\n\nOne thing to note is that the `stdio` streams are not available in this example since the runner disconnects from the background script. To setup `stdio` streams for the background script, they may be specified on the `options` object as an array:\n\n```js\n// setup stdio streams for the background script to write to\nvar stdout = fs.openSync('path/to/stdout.txt', 'a');\nvar stderr = fs.openSync('path/to/stderr.txt', 'a');\n\nvar options = { stdio: [stdout, stderr] };\nbackground.start('my-script.js', options);\n```\n\nSee the [example](example) for more information.\n\n## API\n\n### [.start](index.js#L24)\n\nStart a background script and send the new child process the given options before disconnecting from the child process.\n\n**Params**\n\n* `fp` **{String}**: filepath to the background script\n* `options` **{Object}**: Additional options to send to the child process\n* `returns` **{Number}**: Returns the child process ID.\n\n**Example**\n\n```js\nbackground.start('worker.js', { timeout: 5000 });\n```\n\n### [.ready](index.js#L60)\n\nUse in a child script to know when to start running. The callback function will recieve a possible `Error` object and an `options` object. This is a wrapper for doing `process.on('message', ...)`. This is not something that's required since the runner process will not wait for a response and disconnect. This is a way to send options from the runner to the background script.\n\n**Params**\n\n* `cb` **{Function}**: Callback function that will be executed when the options are recieved from the runner.\n\n**Example**\n\n```js\nbackground.ready(function(err, options) {\n  if (err) return;\n  // do something\n});\n```\n\n## Acknowledgements\n\nMy main goal was to run background scripts from a parent process and still let the parent process exit before the background process finished. In researching how to achieve my goal, I learned a lot from code in [forever](https://github.com/foreverjs/forever) and [forever-monitor](https://github.com/nodejitsu/forever-monitor).\n\n## About\n\n### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\nPlease read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.\n\n### Building docs\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n### Running tests\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n### Author\n\n**Brian Woodward**\n\n* [github/doowb](https://github.com/doowb)\n* [twitter/doowb](https://twitter.com/doowb)\n\n### License\n\nCopyright © 2017, [Brian Woodward](https://github.com/doowb).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on May 08, 2017._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoowb%2Fbackground-process","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoowb%2Fbackground-process","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoowb%2Fbackground-process/lists"}