@mhio/jobs

0.3.2 • Public • Published

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

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)

Readme

Keywords

none

Package Sidebar

Install

npm i @mhio/jobs

Weekly Downloads

2

Version

0.3.2

License

MIT

Unpacked Size

16.5 kB

Total Files

14

Last publish

Collaborators

  • mhio