Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jobbr

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jobbr

  • 1.1.5
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= Jobbr

Jobbr is a Rails engine for supervising your delayed jobs and scheduled jobs (think Cron).

It provides a framework to abstract creation and execution of such jobs and a user interface to supervise jobs and read their logs.

{}[http://travis-ci.org/cblavier/jobbr]

== Screenshots

{}[http://cl.ly/image/3r320L101c3h] {}[http://cl.ly/image/21433N411G01]

== Dependencies

Jobbr has strong dependencies on following components:

  • Mongoid: all jobs are stored in MongoDB for supervision. May be abstracted out later for ActiveRecord compatibility.
  • Whenever: Jobbr uses {Whenever}[https://github.com/javan/whenever] gem to automatically updates Crontab during a Capistrano deployment.

== Setup

Start by adding Jobbr to your Gemfile:

gem 'jobbr'

=== User interface

Then mount Jobbr engine to your routes.rb file.

mount Jobbr::Engine => "/jobbr"

=== Scheduled Jobs

Use provided generators to create a first scheduled job

$> rails g jobbr:scheduled_job dummy

It will create a namespaced model as a well as a Whenever configuration file.

Provided you fill in description and scheduling attributes in the model, you will be able to see it in rake tasks:

$> rake -T | grep jobbr
rake jobbr:dummy_job  # A dummy Job

And to see it in your crontab preview:

$> whenever
30 5 * * * /bin/bash -l -c 'cd /Users/cblavier/code/my_app && RAILS_ENV=production bundle exec rake jobbr:dummy_job >> /Users/cblavier/code/my_app/log/cron.log 2>&1'

=== Heroku Scheduled Jobs

You can also use Heroku Scheduler to run jobs. Unfortunately Heroku does not provide Cron-scheduling, but let you run jobs every 10 minutes, every hour or every day.

Jobbr provides you with 3 tasks jobbr:heroku:minutely, jobbr:heroku:hourly and jobbr:heroku:daily, that will run any ScheduledJob with heroku_run directive.

Run following generator to create an heroku scheduled job

$> rails g jobbr:heroku_scheduled_job dummy_heroku

Then you will need to manually add jobs to the Heroku scheduler console

{}[http://cl.ly/image/2N1T1l1w2c28]

You also need to add an environment variable to let Jobbr know it's running on Heroku

heroku config:add HEROKU=true

=== Delayed Jobs

Use generators to get a new job model:

$> rails g jobbr:delayed_job dummy

You will get a new model with a perform method. Perform parameters are:

  • params: is a hash of parameters for your job.

  • run: is the object that will be persisted (and polled) for this job execution. Your delayed job can use it to provide progress information (to display a progress bar) and a final result.

    run.progress = 100 run.result = 'my job result'

You can now run your delayed job as following:

run_id = DelayedJobs::DummyJob.run_delayed(some_param: 37)

And then get job status like this:

Jobbr::Run.find(run_id).status # returns :waiting / :running / :failure / :success

Jobbr also provides a controller to run and poll delayed_jobs :

  • Post on following url to run your job: delayed_job_creation_path(DelayedJobs::DummyJob, { some_param: 37 })

  • And then poll this url (using the id returned in previous post) to get your job status: delayed_job_polling_path(run_id)

This project rocks and uses MIT-LICENSE.

FAQs

Package last updated on 24 Jan 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc