https://github.com/allnulled/runtime
Spawns new processes from JavaScript functions.
https://github.com/allnulled/runtime
Last synced: about 1 year ago
JSON representation
Spawns new processes from JavaScript functions.
- Host: GitHub
- URL: https://github.com/allnulled/runtime
- Owner: allnulled
- Created: 2024-12-18T08:08:13.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-18T08:10:26.000Z (over 1 year ago)
- Last Synced: 2025-03-30T05:32:56.703Z (about 1 year ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @allnulled/runtime
Spawns new processes from JavaScript functions.
## Installation
```sh
npm i -s @allnulled/runtime
```
## Usage
This script spawns 3 different processes:
```js
const Runtime = require("@allnulled/runtime");
Runtime.start(() => {
setInterval(() => {
console.log("go 1");
}, 1000);
});
Runtime.start(() => {
setInterval(() => {
console.log("go 2");
}, 1000);
});
Runtime.start(() => {
setInterval(() => {
console.log("go 3");
}, 1000);
});
```
Things to now:
- The scripts are saved automatically under `runtimes` folder (from `process.cwd`), each of them with its own id.
- Change the second parameter to another path if you prefer other folder.
- The functions (or callbacks, it does not matter) must not provide any parameter, as it is going to run in a separated different process.
- The scripts are headed with events to remove the file itself when the process is over.