jobbr 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -0
- data/Gemfile.lock +1 -1
- data/README.rdoc +77 -1
- data/app/helpers/jobbr/application_helper.rb +2 -2
- data/config/locales/jobbr.en.yml +4 -0
- data/lib/generators/jobbr/delayed_job/USAGE +8 -0
- data/lib/generators/jobbr/delayed_job/delayed_job_generator.rb +10 -0
- data/lib/generators/jobbr/delayed_job/templates/delayed_job.erb +11 -0
- data/lib/generators/jobbr/scheduled_job/USAGE +10 -0
- data/lib/generators/jobbr/scheduled_job/scheduled_job_generator.rb +11 -0
- data/lib/generators/jobbr/scheduled_job/templates/scheduled_job.erb +15 -0
- data/lib/generators/jobbr/scheduled_job_config/USAGE +8 -0
- data/lib/generators/jobbr/scheduled_job_config/scheduled_job_config_generator.rb +8 -0
- data/lib/generators/jobbr/scheduled_job_config/templates/schedule.rb +8 -0
- data/lib/jobbr/engine.rb +6 -0
- data/lib/jobbr/version.rb +1 -1
- data/spec/dummy/app/controllers/home_controller.rb +3 -0
- data/spec/dummy/app/models/delayed_jobs/dummy_job.rb +11 -0
- data/spec/dummy/app/models/scheduled_jobs/dummy_job.rb +15 -0
- data/spec/dummy/app/views/home/index.html.haml +1 -0
- data/spec/dummy/config/environments/development.rb +2 -2
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/config/schedule.rb +0 -2
- metadata +22 -4
data/.travis.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
services: mongodb
|
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -1,3 +1,79 @@
|
|
1
1
|
= Jobbr
|
2
2
|
|
3
|
-
|
3
|
+
Jobbr is a Rails engine for supervising your delayed jobs and scheduled jobs (think Cron).
|
4
|
+
|
5
|
+
It provides a framework to abstract creation and execution of such jobs and a user interface to supervise jobs and read their logs.
|
6
|
+
|
7
|
+
{<img src="https://secure.travis-ci.org/cblavier/jobbr.png?branch=master" />}[http://travis-ci.org/cblavier/jobbr]
|
8
|
+
|
9
|
+
== Screenshots
|
10
|
+
|
11
|
+
{<img src="http://f.cl.ly/items/0N0G3A3c2A1X2l2s3b3p/Capture%20d%E2%80%99%C3%A9cran%202013-02-12%20%C3%A0%2010.52.05.png" width='400'>}[http://cl.ly/image/3r320L101c3h]
|
12
|
+
{<img src="http://cl.ly/image/21433N411G01/Capture%20d%E2%80%99%C3%A9cran%202013-02-12%20%C3%A0%2010.55.13.png" width='400'>}[http://cl.ly/image/21433N411G01]
|
13
|
+
|
14
|
+
== Dependencies
|
15
|
+
|
16
|
+
Jobbr has strong dependencies on following components:
|
17
|
+
|
18
|
+
* *Mongoid*: all jobs are stored in MongoDB for supervision. May be abstracted out later for ActiveRecord compatibility.
|
19
|
+
* *Whenever*: Jobbr uses {Whenever}[https://github.com/javan/whenever] gem to automatically updates Crontab during a Capistrano deployment.
|
20
|
+
|
21
|
+
== Setup
|
22
|
+
|
23
|
+
Start by adding Jobbr to your Gemfile:
|
24
|
+
|
25
|
+
gem 'jobbr'
|
26
|
+
|
27
|
+
=== User interface
|
28
|
+
|
29
|
+
Then mount Jobbr engine to your `routes.rb` file.
|
30
|
+
|
31
|
+
mount Jobbr::Engine => "/jobbr"
|
32
|
+
|
33
|
+
=== Scheduled Jobs
|
34
|
+
|
35
|
+
Use provided generators to create a first scheduled job
|
36
|
+
|
37
|
+
$> rails g jobbr:scheduled_job dummy
|
38
|
+
|
39
|
+
It will create a namespaced model as a well as a Whenever configuration file.
|
40
|
+
|
41
|
+
Provided you fill in description and scheduling attributes in the model, you will be able to see it in rake tasks:
|
42
|
+
|
43
|
+
$> rake -T | grep jobbr
|
44
|
+
rake jobbr:dummy_job # A dummy Job
|
45
|
+
|
46
|
+
And to see it in your crontab preview:
|
47
|
+
|
48
|
+
$> whenever
|
49
|
+
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'
|
50
|
+
|
51
|
+
=== Delayed Jobs
|
52
|
+
|
53
|
+
Use generators to get a new job model:
|
54
|
+
|
55
|
+
$> rails g jobbr:delayed_job dummy
|
56
|
+
|
57
|
+
You will get a new model with a perform method. Perform parameters are:
|
58
|
+
|
59
|
+
* params: is a hash of parameters for your job.
|
60
|
+
* 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.
|
61
|
+
|
62
|
+
run.progress = 100
|
63
|
+
run.result = 'my job result'
|
64
|
+
|
65
|
+
You can now run your delayed job as following:
|
66
|
+
|
67
|
+
run_id = DelayedJobs::DummyJob.run_delayed(some_param: 37)
|
68
|
+
|
69
|
+
And then get job status like this:
|
70
|
+
|
71
|
+
Jobbr::Run.find(run_id).status # returns :waiting / :running / :failure / :success
|
72
|
+
|
73
|
+
Jobbr also provides a controller to run and poll delayed_jobs :
|
74
|
+
|
75
|
+
* Post on following url to run your job: <tt>delayed_job_creation_path(DelayedJobs::DummyJob, { some_param: 37 })</tt>
|
76
|
+
|
77
|
+
* And then poll this url (using the id returned in previous post) to get your job status: <tt>delayed_job_polling_path(run_id)</tt>
|
78
|
+
|
79
|
+
This project rocks and uses MIT-LICENSE.
|
@@ -2,11 +2,11 @@ module Jobbr
|
|
2
2
|
module ApplicationHelper
|
3
3
|
|
4
4
|
def delayed_job_creation_path(delayed_job_class, params = {})
|
5
|
-
delayed_jobs_path(params.merge(job_name: delayed_job_class.name.underscore))
|
5
|
+
jobbr.delayed_jobs_path(params.merge(job_name: delayed_job_class.name.underscore))
|
6
6
|
end
|
7
7
|
|
8
8
|
def delayed_job_polling_path(id = ':job_id')
|
9
|
-
delayed_job_path(id)
|
9
|
+
jobbr.delayed_job_path(id)
|
10
10
|
end
|
11
11
|
|
12
12
|
def status_icon_class(job_status)
|
data/config/locales/jobbr.en.yml
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
class Jobbr::DelayedJobGenerator < Rails::Generators::NamedBase
|
2
|
+
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
def create_delayed_job
|
6
|
+
empty_directory "app/models/delayed_jobs"
|
7
|
+
template "delayed_job.erb", "app/models/delayed_jobs/#{file_name}_job.rb", name: file_name
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Description:
|
2
|
+
Generates a new scheduled job in ScheduledJobs namespace.
|
3
|
+
Will also create a Whenever configuration file.
|
4
|
+
|
5
|
+
Example:
|
6
|
+
rails generate scheduled_job MySample
|
7
|
+
|
8
|
+
This will create:
|
9
|
+
Model: app/models/scheduled_jobs/my_sample_job.rb
|
10
|
+
Config: config/schedule.rb
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Jobbr::ScheduledJobGenerator < Rails::Generators::NamedBase
|
2
|
+
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
def create_scheduled_job
|
6
|
+
empty_directory "app/models/scheduled_jobs"
|
7
|
+
template "scheduled_job.erb", "app/models/scheduled_jobs/#{file_name}_job.rb", name: file_name
|
8
|
+
generate 'jobbr:scheduled_job_config'
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
ENV['RAILS_ENV'] = ARGV.first || ENV['RAILS_ENV'] || 'development'
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
3
|
+
require "jobbr/whenever"
|
4
|
+
|
5
|
+
set :output, "#{path}/log/cron.log"
|
6
|
+
job_type :rake, "cd :path && RAILS_ENV=:environment bundle exec rake :task :output"
|
7
|
+
|
8
|
+
Jobbr::Whenever.schedule_jobs(self)
|
data/lib/jobbr/engine.rb
CHANGED
data/lib/jobbr/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
= delayed_job_polling_path
|
@@ -23,11 +23,11 @@ Dummy::Application.configure do
|
|
23
23
|
config.action_dispatch.best_standards_support = :builtin
|
24
24
|
|
25
25
|
# Raise exception on mass assignment protection for Active Record models
|
26
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
26
|
+
# config.active_record.mass_assignment_sanitizer = :strict
|
27
27
|
|
28
28
|
# Log the query plan for queries taking more than this (works
|
29
29
|
# with SQLite, MySQL, and PostgreSQL)
|
30
|
-
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
30
|
+
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
31
31
|
|
32
32
|
# Do not compress assets
|
33
33
|
config.assets.compress = false
|
data/spec/dummy/config/routes.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jobbr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -117,6 +117,7 @@ extra_rdoc_files: []
|
|
117
117
|
files:
|
118
118
|
- .gitignore
|
119
119
|
- .rspec
|
120
|
+
- .travis.yml
|
120
121
|
- Gemfile
|
121
122
|
- Gemfile.lock
|
122
123
|
- MIT-LICENSE
|
@@ -145,6 +146,15 @@ files:
|
|
145
146
|
- config/locales/jobbr.en.yml
|
146
147
|
- config/routes.rb
|
147
148
|
- jobbr.gemspec
|
149
|
+
- lib/generators/jobbr/delayed_job/USAGE
|
150
|
+
- lib/generators/jobbr/delayed_job/delayed_job_generator.rb
|
151
|
+
- lib/generators/jobbr/delayed_job/templates/delayed_job.erb
|
152
|
+
- lib/generators/jobbr/scheduled_job/USAGE
|
153
|
+
- lib/generators/jobbr/scheduled_job/scheduled_job_generator.rb
|
154
|
+
- lib/generators/jobbr/scheduled_job/templates/scheduled_job.erb
|
155
|
+
- lib/generators/jobbr/scheduled_job_config/USAGE
|
156
|
+
- lib/generators/jobbr/scheduled_job_config/scheduled_job_config_generator.rb
|
157
|
+
- lib/generators/jobbr/scheduled_job_config/templates/schedule.rb
|
148
158
|
- lib/jobbr.rb
|
149
159
|
- lib/jobbr/engine.rb
|
150
160
|
- lib/jobbr/logger.rb
|
@@ -158,10 +168,14 @@ files:
|
|
158
168
|
- spec/dummy/app/assets/javascripts/application.js
|
159
169
|
- spec/dummy/app/assets/stylesheets/application.css
|
160
170
|
- spec/dummy/app/controllers/application_controller.rb
|
171
|
+
- spec/dummy/app/controllers/home_controller.rb
|
161
172
|
- spec/dummy/app/helpers/application_helper.rb
|
162
173
|
- spec/dummy/app/mailers/.gitkeep
|
163
174
|
- spec/dummy/app/models/.gitkeep
|
175
|
+
- spec/dummy/app/models/delayed_jobs/dummy_job.rb
|
176
|
+
- spec/dummy/app/models/scheduled_jobs/dummy_job.rb
|
164
177
|
- spec/dummy/app/models/scheduled_jobs/dummy_scheduled_job.rb
|
178
|
+
- spec/dummy/app/views/home/index.html.haml
|
165
179
|
- spec/dummy/app/views/layouts/application.html.erb
|
166
180
|
- spec/dummy/config.ru
|
167
181
|
- spec/dummy/config/application.rb
|
@@ -216,7 +230,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
230
|
version: '0'
|
217
231
|
segments:
|
218
232
|
- 0
|
219
|
-
hash:
|
233
|
+
hash: -3816807039260850445
|
220
234
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
235
|
none: false
|
222
236
|
requirements:
|
@@ -225,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
239
|
version: '0'
|
226
240
|
segments:
|
227
241
|
- 0
|
228
|
-
hash:
|
242
|
+
hash: -3816807039260850445
|
229
243
|
requirements: []
|
230
244
|
rubyforge_project:
|
231
245
|
rubygems_version: 1.8.23
|
@@ -238,10 +252,14 @@ test_files:
|
|
238
252
|
- spec/dummy/app/assets/javascripts/application.js
|
239
253
|
- spec/dummy/app/assets/stylesheets/application.css
|
240
254
|
- spec/dummy/app/controllers/application_controller.rb
|
255
|
+
- spec/dummy/app/controllers/home_controller.rb
|
241
256
|
- spec/dummy/app/helpers/application_helper.rb
|
242
257
|
- spec/dummy/app/mailers/.gitkeep
|
243
258
|
- spec/dummy/app/models/.gitkeep
|
259
|
+
- spec/dummy/app/models/delayed_jobs/dummy_job.rb
|
260
|
+
- spec/dummy/app/models/scheduled_jobs/dummy_job.rb
|
244
261
|
- spec/dummy/app/models/scheduled_jobs/dummy_scheduled_job.rb
|
262
|
+
- spec/dummy/app/views/home/index.html.haml
|
245
263
|
- spec/dummy/app/views/layouts/application.html.erb
|
246
264
|
- spec/dummy/config.ru
|
247
265
|
- spec/dummy/config/application.rb
|