cantina-cron

An amino/redis-powered in-app crontab.

Usage no npm install needed!

<script type="module">
  import cantinaCron from 'https://cdn.skypack.dev/cantina-cron';
</script>

README

cantina-cron

An amino/redis-powered in-app crontab.

Dependencies

Provides

  • app.cron - The Cron API

Configuration

Though you can manually schedule jobs via the api, the more common way to setup your's app's jobs is through your configuration.

{
  "cron": {
    "active": true
    "jobs": [
      {
        title: 'News Aggregator'
        cronTime: '* * * * *'
        queue: 'aggregator:queue'
        payload: {}
      },
      {
        title: 'Check Approaching Resource Expiration'
        cronTime: '0 0 * * *'
        queue: 'resource:expiration:check'
        payload: {}
      }
    ]
  }
}

Usage

If app.conf.get('cron:active') === true then your cron jobs will start being polled as soon as app.start() is called. The queue values of jobs should map to queue workers in your app.

API

app.cron.schedule (job)

Schedule a job. See the config example above for job format.

app.cron.start

Start the cron interval.

app.cron.stop

Stop the cron interval.

app.cron.poll

Manually trigger a poll through the cron jobs.


Developed by TerraEclipse

Terra Eclipse, Inc. is a nationally recognized political technology and strategy firm located in Santa Cruz, CA and Washington, D.C.