mcmire-delayed_job_web 1.1.3.rc1 → 1.1.3.rc2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/README.markdown +61 -7
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/lib/delayed_job_web/application/app.rb +60 -12
- data/lib/delayed_job_web/application/public/stylesheets/style.css +3 -3
- data/lib/delayed_job_web/application/views/enqueued.haml +1 -1
- data/lib/delayed_job_web/application/views/overview.haml +5 -11
- data/lib/delayed_job_web/application/views/stats.haml +3 -3
- data/mcmire-delayed_job_web.gemspec +1 -1
- metadata +3 -3
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -1,16 +1,23 @@
|
|
1
|
+
About this Fork
|
2
|
+
===============
|
3
|
+
|
4
|
+
This fork by [@mcmire][2] adds Rails 2.x support, and also removes the
|
5
|
+
"enqueued" tab from the UI (because I didn't see a need for it). I also updated
|
6
|
+
the README below.
|
7
|
+
|
8
|
+
---
|
9
|
+
|
1
10
|
delayed_job_web
|
2
11
|
===============
|
3
12
|
|
4
|
-
A [resque][0] inspired (read: stolen) interface for delayed_job.
|
5
|
-
|
6
|
-
activerecord.
|
13
|
+
A [resque][0] inspired (read: stolen) interface for delayed_job. This gem is
|
14
|
+
written to work with Rails 2 and 3 applications using activerecord.
|
7
15
|
|
8
16
|
Some features:
|
9
17
|
|
10
|
-
* Easily view
|
11
|
-
* Queue any single job
|
18
|
+
* Easily view pending, working, and failed jobs.
|
19
|
+
* Queue any single job, or all pending jobs, to run immediately.
|
12
20
|
* Remove a failed job, or easily remove all failed jobs.
|
13
|
-
* Watch delayed_job operation with live ajax polling.
|
14
21
|
|
15
22
|
Quick Start For Rails 3 Applications
|
16
23
|
------------------------------------
|
@@ -33,16 +40,62 @@ Add a route to your application for accessing the interface
|
|
33
40
|
match "/delayed_job" => DelayedJobWeb, :anchor => false
|
34
41
|
```
|
35
42
|
|
36
|
-
You probably want to password protect the interface, an easy way is to add
|
43
|
+
You probably want to password protect the interface, an easy way is to add
|
44
|
+
something like this your config.ru file
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
if Rails.env.production?
|
48
|
+
DelayedJobWeb.use Rack::Auth::Basic do |username, password|
|
49
|
+
username == 'username' && password == 'password'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
Quick Start For Rails 2.x Applications
|
55
|
+
--------------------------------------
|
56
|
+
|
57
|
+
Yes, this works for older Rails apps too, but it requires a little bit of extra
|
58
|
+
work.
|
59
|
+
|
60
|
+
First, in starting your app you will have to go outside of the Rails framework a
|
61
|
+
bit. Rails 2.x doesn't have the concept of mountable apps, but Rack does. So
|
62
|
+
if you want to access the DelayedJob interface, you'll need to start your app
|
63
|
+
Rack-style.
|
64
|
+
|
65
|
+
First begin by adding a config.ru file that looks something like this:
|
37
66
|
|
38
67
|
```ruby
|
68
|
+
require File.dirname(__FILE__) + '/config/environment'
|
69
|
+
|
70
|
+
# For some reason this doesn't happen automatically anymore
|
71
|
+
Delayed::Worker.guess_backend
|
72
|
+
|
39
73
|
if Rails.env.production?
|
40
74
|
DelayedJobWeb.use Rack::Auth::Basic do |username, password|
|
41
75
|
username == 'username' && password == 'password'
|
42
76
|
end
|
43
77
|
end
|
78
|
+
|
79
|
+
app = Rack::Builder.new {
|
80
|
+
use Rails::Rack::Static
|
81
|
+
|
82
|
+
map "/delayed_jobs" do
|
83
|
+
run DelayedJobWeb.new
|
84
|
+
end
|
85
|
+
|
86
|
+
map "/" do
|
87
|
+
run ActionController::Dispatcher.new
|
88
|
+
end
|
89
|
+
}.to_app
|
90
|
+
|
91
|
+
run app
|
44
92
|
```
|
45
93
|
|
94
|
+
Now to run your Rails app, use `rackup` instead of `script/server`. In
|
95
|
+
production, you will obviously want to make sure whatever you are using to run
|
96
|
+
your app does this as well. (Passenger does by default.)
|
97
|
+
|
98
|
+
|
46
99
|
The Interface - Yea, a ripoff of resque-web
|
47
100
|
------------------------------------
|
48
101
|
|
@@ -59,3 +112,4 @@ Erick Schmitt - [@ejschmitt][1]
|
|
59
112
|
|
60
113
|
[0]: https://github.com/defunkt/resque
|
61
114
|
[1]: http://twitter.com/ejschmitt
|
115
|
+
[2]: http://github.com/mcmire
|
data/Rakefile
CHANGED
@@ -14,13 +14,13 @@ require 'rake'
|
|
14
14
|
require 'jeweler'
|
15
15
|
Jeweler::Tasks.new do |gem|
|
16
16
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.name = "delayed_job_web"
|
17
|
+
gem.name = "mcmire-delayed_job_web"
|
18
18
|
gem.homepage = "http://github.com/ejschmitt/delayed_job_web"
|
19
19
|
gem.license = "MIT"
|
20
20
|
gem.summary = "Web interface for delayed_job"
|
21
21
|
gem.description = "Web interface for delayed_job inspired by resque"
|
22
22
|
gem.email = "ejschmitt@gmail.com"
|
23
|
-
gem.authors = ["Erick Schmitt"]
|
23
|
+
gem.authors = ["Erick Schmitt", "Elliot Winkler"]
|
24
24
|
# dependencies defined in Gemfile
|
25
25
|
end
|
26
26
|
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.3.rc2
|
@@ -35,9 +35,8 @@ class DelayedJobWeb < Sinatra::Base
|
|
35
35
|
def tabs
|
36
36
|
[
|
37
37
|
{:name => 'Overview', :path => '/overview'},
|
38
|
-
{:name => 'Enqueued', :path => '/enqueued'},
|
39
|
-
{:name => 'Working', :path => '/working'},
|
40
38
|
{:name => 'Pending', :path => '/pending'},
|
39
|
+
{:name => 'Working', :path => '/working'},
|
41
40
|
{:name => 'Failed', :path => '/failed'},
|
42
41
|
{:name => 'Stats', :path => '/stats'}
|
43
42
|
]
|
@@ -66,41 +65,90 @@ class DelayedJobWeb < Sinatra::Base
|
|
66
65
|
|
67
66
|
%w(enqueued working pending failed).each do |page|
|
68
67
|
get "/#{page}" do
|
69
|
-
@jobs =
|
70
|
-
|
68
|
+
@jobs = find_all_jobs(page.to_sym,
|
69
|
+
:order => 'created_at desc, id desc',
|
70
|
+
:offset => start,
|
71
|
+
:limit => per_page
|
72
|
+
)
|
73
|
+
@all_jobs = find_all_jobs(page.to_sym)
|
71
74
|
haml page.to_sym
|
72
75
|
end
|
73
76
|
end
|
74
77
|
|
75
78
|
get "/remove/:id" do
|
76
|
-
|
79
|
+
remove_job(params[:id])
|
77
80
|
redirect back
|
78
81
|
end
|
79
82
|
|
80
83
|
get "/requeue/:id" do
|
81
|
-
|
82
|
-
job.update_attributes(:run_at => Time.now, :failed_at => nil)
|
84
|
+
update_job(params[:id], :run_at => Time.now, :failed_at => nil)
|
83
85
|
redirect back
|
84
86
|
end
|
85
87
|
|
86
88
|
post "/failed/clear" do
|
87
|
-
|
89
|
+
remove_jobs(:failed)
|
88
90
|
redirect u('failed')
|
89
91
|
end
|
90
92
|
|
91
93
|
post "/requeue/all" do
|
92
|
-
|
94
|
+
requeue_failed_jobs
|
93
95
|
redirect back
|
94
96
|
end
|
95
97
|
|
96
|
-
def
|
97
|
-
|
98
|
+
def find_all_jobs(type, opts={})
|
99
|
+
conditions = delayed_job_sql(type)
|
100
|
+
if Rails.version.to_s =~ /^2/
|
101
|
+
delayed_job.find(:all, {:conditions => conditions}.merge(opts))
|
102
|
+
else
|
103
|
+
scope = delayed_job.where(conditions)
|
104
|
+
scope.order(opts[:order]) if opts[:order]
|
105
|
+
scope.offset(opts[:offset]) if opts[:offset]
|
106
|
+
scope.limit(opts[:limit]) if opts[:limit]
|
107
|
+
scope
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def count_all_jobs(type=nil)
|
112
|
+
if type.nil?
|
113
|
+
return delayed_job.count
|
114
|
+
end
|
115
|
+
if Rails.version.to_s =~ /^2/
|
116
|
+
delayed_job.count(:conditions => delayed_job_sql(type))
|
117
|
+
else
|
118
|
+
find_all_jobs(type).count
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def find_job(id)
|
123
|
+
delayed_job.find(id)
|
124
|
+
end
|
125
|
+
|
126
|
+
def update_job(id, attrs)
|
127
|
+
job = find_job(id)
|
128
|
+
job.update_attributes(attrs)
|
129
|
+
end
|
130
|
+
|
131
|
+
def remove_job(id)
|
132
|
+
find_job(id).delete
|
133
|
+
end
|
134
|
+
|
135
|
+
def remove_jobs(type)
|
136
|
+
delayed_job.destroy_all(delayed_job_sql(type))
|
137
|
+
end
|
138
|
+
|
139
|
+
def requeue_failed_jobs
|
140
|
+
updates = {:run_at => Time.now, :failed_at => nil}
|
141
|
+
if Rails.version.to_s =~ /^2/
|
142
|
+
delayed_job.update_all(updates, delayed_job_sql(:failed))
|
143
|
+
else
|
144
|
+
find_all_jobs(:failed).update_all(updates)
|
145
|
+
end
|
98
146
|
end
|
99
147
|
|
100
148
|
def delayed_job_sql(type)
|
101
149
|
case type
|
102
150
|
when :enqueued
|
103
|
-
''
|
151
|
+
'run_at is null or (run_at is not null and last_error is null)'
|
104
152
|
when :working
|
105
153
|
'locked_at is not null'
|
106
154
|
when :failed
|
@@ -36,9 +36,9 @@ pre { font-family:Courier New; line-height:1.4em; }
|
|
36
36
|
|
37
37
|
#main table.overview { width:40%;}
|
38
38
|
#main table.overview td.status { font-weight:bold; width:50%;}
|
39
|
-
#main table.overview tr.failed td { border-top:2px solid;
|
40
|
-
#main table.overview tr.failure td { background:#ffecec;
|
41
|
-
#main table.overview tr.failure td a{ color:#
|
39
|
+
#main table.overview tr.failed td { border-top:2px solid; }
|
40
|
+
#main table.overview tr.failure td { background:#ffecec; color:#E03434; }
|
41
|
+
#main table.overview tr.failure td a{ color:#E03434; }
|
42
42
|
|
43
43
|
#main table.jobs td.class { font-family:Monaco, "Courier New", monospace; font-size:90%; width:50%;}
|
44
44
|
#main table.jobs td.args{ width:50%;}
|
@@ -1,25 +1,19 @@
|
|
1
1
|
%h1
|
2
2
|
Overview
|
3
|
-
%p.sub
|
4
|
-
The list below shows an overview of the jobs in the delayed_job queue.
|
5
3
|
%table.overview
|
6
4
|
%tr
|
7
5
|
%th Status
|
8
6
|
%th Count
|
9
7
|
%tr
|
10
8
|
%td.status
|
11
|
-
%a{:href => u('/
|
12
|
-
%td=
|
9
|
+
%a{:href => u('/pending')} Pending Jobs
|
10
|
+
%td= count_all_jobs(:pending)
|
13
11
|
%tr
|
14
12
|
%td.status
|
15
13
|
%a{:href => u('/working')} Working Jobs
|
16
|
-
%td=
|
17
|
-
%tr
|
18
|
-
%td.status
|
19
|
-
%a{:href => u('/pending')} Pending Jobs
|
20
|
-
%td= delayed_jobs(:pending).count
|
21
|
-
%tr{:class => delayed_jobs(:failed).count > 0 ? 'failure' : ''}
|
14
|
+
%td= count_all_jobs(:working)
|
15
|
+
%tr{:class => count_all_jobs(:failed) > 0 ? 'failure' : ''}
|
22
16
|
%td.status
|
23
17
|
%a{:href => u('/failed')} Failed Jobs
|
24
|
-
%td=
|
18
|
+
%td= count_all_jobs(:failed)
|
25
19
|
= poll
|
@@ -8,13 +8,13 @@
|
|
8
8
|
%tr
|
9
9
|
%th.status
|
10
10
|
failed
|
11
|
-
%th=
|
11
|
+
%th= count_all_jobs(:failed)
|
12
12
|
%tr
|
13
13
|
%th.status
|
14
14
|
pending
|
15
|
-
%th=
|
15
|
+
%th= count_all_jobs(:pending)
|
16
16
|
%tr
|
17
17
|
%th.status
|
18
18
|
working
|
19
|
-
%th=
|
19
|
+
%th= count_all_jobs(:working)
|
20
20
|
= poll
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mcmire-delayed_job_web}
|
8
|
-
s.version = "1.1.3.
|
8
|
+
s.version = "1.1.3.rc2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Erick Schmitt", "Elliot Winkler"]
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mcmire-delayed_job_web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15424057
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
9
|
- 3
|
10
10
|
- rc
|
11
|
-
-
|
12
|
-
version: 1.1.3.
|
11
|
+
- 2
|
12
|
+
version: 1.1.3.rc2
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Erick Schmitt
|