https://github.com/mhio/node-jobs
Process Job manager
https://github.com/mhio/node-jobs
javascript jobs nodejs process spawn
Last synced: 11 months ago
JSON representation
Process Job manager
- Host: GitHub
- URL: https://github.com/mhio/node-jobs
- Owner: mhio
- License: mit
- Created: 2018-03-11T06:10:12.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2023-03-04T04:06:34.000Z (almost 3 years ago)
- Last Synced: 2025-03-18T04:58:10.611Z (11 months ago)
- Topics: javascript, jobs, nodejs, process, spawn
- Language: JavaScript
- Homepage:
- Size: 202 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Jobs
----------
Manage a process as a Job.
Execute a Job, recieve an ID
Query the start of the Job.
## Install
```
yarn add @mhio/job
npm install @mhio/job
```
## Usage
[API Docs](doc/API.md)
```
import { Job } from '@mhio/job'
let job = new Job({ command: [ 'printf', '%s\n%s\n', 'one', 'two' ] })
try {
console.log('Job ID %s', job.id)
await job.run() // resolves to the same `job` instance
console.log(job.output)
} catch (err) {
console.error(err)
console.error('Job output', job.output)
}
```
```
import { Jobs } from '@mhio/job'
let jobs = new Jobs()
let job = jobs.createJob({ command: [ 'sh', '-c', 'echo running; sleep 4; exit 2' ] })
job.run().catch(err => console.error(err) // resolves to the same `job` instance
console.log('Job "%s" running in the background', job.id)
```