workless 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -2
- data/Gemfile.lock +49 -49
- data/README.textile +4 -1
- data/Rakefile +0 -1
- data/VERSION +1 -1
- data/lib/workless/scalers/heroku_cedar.rb +33 -0
- data/workless.gemspec +3 -17
- metadata +13 -48
- data/test/helper.rb +0 -10
- data/test/test_workless.rb +0 -7
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,88 +2,89 @@ GEM
|
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
4
|
abstract (1.0.0)
|
5
|
-
actionmailer (3.0.
|
6
|
-
actionpack (= 3.0.
|
7
|
-
mail (~> 2.2.
|
8
|
-
actionpack (3.0.
|
9
|
-
activemodel (= 3.0.
|
10
|
-
activesupport (= 3.0.
|
5
|
+
actionmailer (3.0.9)
|
6
|
+
actionpack (= 3.0.9)
|
7
|
+
mail (~> 2.2.19)
|
8
|
+
actionpack (3.0.9)
|
9
|
+
activemodel (= 3.0.9)
|
10
|
+
activesupport (= 3.0.9)
|
11
11
|
builder (~> 2.1.2)
|
12
12
|
erubis (~> 2.6.6)
|
13
|
-
i18n (~> 0.
|
13
|
+
i18n (~> 0.5.0)
|
14
14
|
rack (~> 1.2.1)
|
15
|
-
rack-mount (~> 0.6.
|
16
|
-
rack-test (~> 0.5.
|
15
|
+
rack-mount (~> 0.6.14)
|
16
|
+
rack-test (~> 0.5.7)
|
17
17
|
tzinfo (~> 0.3.23)
|
18
|
-
activemodel (3.0.
|
19
|
-
activesupport (= 3.0.
|
18
|
+
activemodel (3.0.9)
|
19
|
+
activesupport (= 3.0.9)
|
20
20
|
builder (~> 2.1.2)
|
21
|
-
i18n (~> 0.
|
22
|
-
activerecord (3.0.
|
23
|
-
activemodel (= 3.0.
|
24
|
-
activesupport (= 3.0.
|
25
|
-
arel (~> 2.0.
|
21
|
+
i18n (~> 0.5.0)
|
22
|
+
activerecord (3.0.9)
|
23
|
+
activemodel (= 3.0.9)
|
24
|
+
activesupport (= 3.0.9)
|
25
|
+
arel (~> 2.0.10)
|
26
26
|
tzinfo (~> 0.3.23)
|
27
|
-
activeresource (3.0.
|
28
|
-
activemodel (= 3.0.
|
29
|
-
activesupport (= 3.0.
|
30
|
-
activesupport (3.0.
|
31
|
-
arel (2.0.
|
27
|
+
activeresource (3.0.9)
|
28
|
+
activemodel (= 3.0.9)
|
29
|
+
activesupport (= 3.0.9)
|
30
|
+
activesupport (3.0.9)
|
31
|
+
arel (2.0.10)
|
32
32
|
builder (2.1.2)
|
33
|
-
configuration (1.
|
34
|
-
daemons (1.1.
|
35
|
-
delayed_job (2.1.
|
33
|
+
configuration (1.3.1)
|
34
|
+
daemons (1.1.4)
|
35
|
+
delayed_job (2.1.4)
|
36
36
|
activesupport (~> 3.0)
|
37
37
|
daemons
|
38
38
|
erubis (2.6.6)
|
39
39
|
abstract (>= 1.0.0)
|
40
40
|
fattr (2.2.0)
|
41
|
-
heroku (
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
heroku (2.3.6)
|
42
|
+
launchy (>= 0.3.2)
|
43
|
+
rest-client (~> 1.6.1)
|
44
|
+
term-ansicolor (~> 1.0.5)
|
45
45
|
i18n (0.5.0)
|
46
|
-
|
47
|
-
launchy (0.3.7)
|
46
|
+
launchy (0.4.0)
|
48
47
|
configuration (>= 0.0.5)
|
49
48
|
rake (>= 0.8.1)
|
50
|
-
mail (2.2.
|
49
|
+
mail (2.2.19)
|
51
50
|
activesupport (>= 2.3.6)
|
52
51
|
i18n (>= 0.4.0)
|
53
52
|
mime-types (~> 1.16)
|
54
53
|
treetop (~> 1.4.8)
|
55
54
|
mime-types (1.16)
|
56
55
|
polyglot (0.3.1)
|
57
|
-
rack (1.2.
|
58
|
-
rack-mount (0.6.
|
56
|
+
rack (1.2.3)
|
57
|
+
rack-mount (0.6.14)
|
59
58
|
rack (>= 1.0.0)
|
60
|
-
rack-test (0.5.
|
59
|
+
rack-test (0.5.7)
|
61
60
|
rack (>= 1.0)
|
62
|
-
rails (3.0.
|
63
|
-
actionmailer (= 3.0.
|
64
|
-
actionpack (= 3.0.
|
65
|
-
activerecord (= 3.0.
|
66
|
-
activeresource (= 3.0.
|
67
|
-
activesupport (= 3.0.
|
61
|
+
rails (3.0.9)
|
62
|
+
actionmailer (= 3.0.9)
|
63
|
+
actionpack (= 3.0.9)
|
64
|
+
activerecord (= 3.0.9)
|
65
|
+
activeresource (= 3.0.9)
|
66
|
+
activesupport (= 3.0.9)
|
68
67
|
bundler (~> 1.0)
|
69
|
-
railties (= 3.0.
|
70
|
-
railties (3.0.
|
71
|
-
actionpack (= 3.0.
|
72
|
-
activesupport (= 3.0.
|
68
|
+
railties (= 3.0.9)
|
69
|
+
railties (3.0.9)
|
70
|
+
actionpack (= 3.0.9)
|
71
|
+
activesupport (= 3.0.9)
|
73
72
|
rake (>= 0.8.7)
|
73
|
+
rdoc (~> 3.4)
|
74
74
|
thor (~> 0.14.4)
|
75
|
-
rake (0.
|
76
|
-
|
75
|
+
rake (0.9.2)
|
76
|
+
rdoc (3.8)
|
77
|
+
rest-client (1.6.3)
|
77
78
|
mime-types (>= 1.16)
|
78
79
|
rush (0.6.7)
|
79
80
|
session
|
80
81
|
session (3.1.0)
|
81
82
|
fattr
|
83
|
+
term-ansicolor (1.0.5)
|
82
84
|
thor (0.14.6)
|
83
|
-
thoughtbot-shoulda (2.11.1)
|
84
85
|
treetop (1.4.9)
|
85
86
|
polyglot (>= 0.3.1)
|
86
|
-
tzinfo (0.3.
|
87
|
+
tzinfo (0.3.29)
|
87
88
|
|
88
89
|
PLATFORMS
|
89
90
|
ruby
|
@@ -93,4 +94,3 @@ DEPENDENCIES
|
|
93
94
|
heroku
|
94
95
|
rails (>= 3.0.0)
|
95
96
|
rush (= 0.6.7)
|
96
|
-
thoughtbot-shoulda
|
data/README.textile
CHANGED
@@ -37,15 +37,18 @@ config.after_initialize do
|
|
37
37
|
end
|
38
38
|
</pre>
|
39
39
|
|
40
|
-
There are
|
40
|
+
There are three other scalers included. Note that if you are running on the Aspen or Bamboo stacks on Heroku and you don't explicitly specify the scaler, the heroku scaler will be used automatically.
|
41
41
|
|
42
42
|
<pre>
|
43
43
|
Delayed::Job.scaler = :heroku
|
44
|
+
Delayed::Job.scaler = :heroku_cedar
|
44
45
|
Delayed::Job.scaler = :local
|
45
46
|
</pre>
|
46
47
|
|
47
48
|
The local scaler uses @adamwiggins rush library http://github.com/adamwiggins/rush to start and stop workers on a local machine
|
48
49
|
|
50
|
+
The heroku scaler works on the Aspen and Bamboo stacks while the heroku_cedar scaler only works on the new Cedar stack.
|
51
|
+
|
49
52
|
h2. Note on Patches/Pull Requests
|
50
53
|
|
51
54
|
* Please fork the project, as you can see there are no tests and at present I don't know how to go about adding them so any advice would be welcome.
|
data/Rakefile
CHANGED
@@ -12,7 +12,6 @@ begin
|
|
12
12
|
gem.email = "paul.crabtree@gmail.com"
|
13
13
|
gem.homepage = "http://github.com/lostboy/workless"
|
14
14
|
gem.authors = ["lostboy"]
|
15
|
-
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
16
15
|
gem.add_bundler_dependencies
|
17
16
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
17
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'heroku'
|
2
|
+
|
3
|
+
module Delayed
|
4
|
+
module Workless
|
5
|
+
module Scaler
|
6
|
+
|
7
|
+
class HerokuCedar < Base
|
8
|
+
|
9
|
+
require "heroku"
|
10
|
+
|
11
|
+
def up
|
12
|
+
client.ps_scale(ENV['APP_NAME'], type: 'worker', qty: 1) if workers == 0
|
13
|
+
end
|
14
|
+
|
15
|
+
def down
|
16
|
+
client.ps_scale(ENV['APP_NAME'], type: 'worker', qty: 0) unless workers == 0 or jobs.count > 0
|
17
|
+
end
|
18
|
+
|
19
|
+
def workers
|
20
|
+
client.ps(ENV['APP_NAME']).count { |p| p["process"] =~ /worker\.\d?/ }
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def client
|
26
|
+
@client ||= ::Heroku::Client.new(ENV['HEROKU_USER'], ENV['HEROKU_PASSWORD'])
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/workless.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{workless}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["lostboy"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-06-30}
|
13
13
|
s.description = %q{Extension to Delayed Job to enable workers to scale up when needed}
|
14
14
|
s.email = %q{paul.crabtree@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -31,20 +31,15 @@ Gem::Specification.new do |s|
|
|
31
31
|
"lib/workless/scaler.rb",
|
32
32
|
"lib/workless/scalers/base.rb",
|
33
33
|
"lib/workless/scalers/heroku.rb",
|
34
|
+
"lib/workless/scalers/heroku_cedar.rb",
|
34
35
|
"lib/workless/scalers/local.rb",
|
35
36
|
"lib/workless/scalers/null.rb",
|
36
|
-
"test/helper.rb",
|
37
|
-
"test/test_workless.rb",
|
38
37
|
"workless.gemspec"
|
39
38
|
]
|
40
39
|
s.homepage = %q{http://github.com/lostboy/workless}
|
41
40
|
s.require_paths = ["lib"]
|
42
41
|
s.rubygems_version = %q{1.5.0}
|
43
42
|
s.summary = %q{Use delayed job workers only when theyre needed}
|
44
|
-
s.test_files = [
|
45
|
-
"test/helper.rb",
|
46
|
-
"test/test_workless.rb"
|
47
|
-
]
|
48
43
|
|
49
44
|
if s.respond_to? :specification_version then
|
50
45
|
s.specification_version = 3
|
@@ -54,38 +49,29 @@ Gem::Specification.new do |s|
|
|
54
49
|
s.add_runtime_dependency(%q<heroku>, [">= 0"])
|
55
50
|
s.add_runtime_dependency(%q<rush>, ["= 0.6.7"])
|
56
51
|
s.add_runtime_dependency(%q<delayed_job>, ["~> 2.1.0"])
|
57
|
-
s.add_runtime_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
58
|
-
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
59
52
|
s.add_runtime_dependency(%q<rails>, [">= 3.0.0"])
|
60
53
|
s.add_runtime_dependency(%q<heroku>, [">= 0"])
|
61
54
|
s.add_runtime_dependency(%q<rush>, ["= 0.6.7"])
|
62
55
|
s.add_runtime_dependency(%q<delayed_job>, ["~> 2.1.0"])
|
63
|
-
s.add_runtime_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
64
56
|
else
|
65
57
|
s.add_dependency(%q<rails>, [">= 3.0.0"])
|
66
58
|
s.add_dependency(%q<heroku>, [">= 0"])
|
67
59
|
s.add_dependency(%q<rush>, ["= 0.6.7"])
|
68
60
|
s.add_dependency(%q<delayed_job>, ["~> 2.1.0"])
|
69
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
70
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
71
61
|
s.add_dependency(%q<rails>, [">= 3.0.0"])
|
72
62
|
s.add_dependency(%q<heroku>, [">= 0"])
|
73
63
|
s.add_dependency(%q<rush>, ["= 0.6.7"])
|
74
64
|
s.add_dependency(%q<delayed_job>, ["~> 2.1.0"])
|
75
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
76
65
|
end
|
77
66
|
else
|
78
67
|
s.add_dependency(%q<rails>, [">= 3.0.0"])
|
79
68
|
s.add_dependency(%q<heroku>, [">= 0"])
|
80
69
|
s.add_dependency(%q<rush>, ["= 0.6.7"])
|
81
70
|
s.add_dependency(%q<delayed_job>, ["~> 2.1.0"])
|
82
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
83
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
84
71
|
s.add_dependency(%q<rails>, [">= 3.0.0"])
|
85
72
|
s.add_dependency(%q<heroku>, [">= 0"])
|
86
73
|
s.add_dependency(%q<rush>, ["= 0.6.7"])
|
87
74
|
s.add_dependency(%q<delayed_job>, ["~> 2.1.0"])
|
88
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
89
75
|
end
|
90
76
|
end
|
91
77
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: workless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- lostboy
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-06-30 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -57,31 +57,9 @@ dependencies:
|
|
57
57
|
type: :runtime
|
58
58
|
prerelease: false
|
59
59
|
version_requirements: *id004
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
|
-
name: thoughtbot-shoulda
|
62
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
|
-
requirements:
|
65
|
-
- - ">="
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: "0"
|
68
|
-
type: :runtime
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: *id005
|
71
|
-
- !ruby/object:Gem::Dependency
|
72
|
-
name: thoughtbot-shoulda
|
73
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
|
-
requirements:
|
76
|
-
- - ">="
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: "0"
|
79
|
-
type: :development
|
80
|
-
prerelease: false
|
81
|
-
version_requirements: *id006
|
82
60
|
- !ruby/object:Gem::Dependency
|
83
61
|
name: rails
|
84
|
-
requirement: &
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
63
|
none: false
|
86
64
|
requirements:
|
87
65
|
- - ">="
|
@@ -89,10 +67,10 @@ dependencies:
|
|
89
67
|
version: 3.0.0
|
90
68
|
type: :runtime
|
91
69
|
prerelease: false
|
92
|
-
version_requirements: *
|
70
|
+
version_requirements: *id005
|
93
71
|
- !ruby/object:Gem::Dependency
|
94
72
|
name: heroku
|
95
|
-
requirement: &
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
96
74
|
none: false
|
97
75
|
requirements:
|
98
76
|
- - ">="
|
@@ -100,10 +78,10 @@ dependencies:
|
|
100
78
|
version: "0"
|
101
79
|
type: :runtime
|
102
80
|
prerelease: false
|
103
|
-
version_requirements: *
|
81
|
+
version_requirements: *id006
|
104
82
|
- !ruby/object:Gem::Dependency
|
105
83
|
name: rush
|
106
|
-
requirement: &
|
84
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
107
85
|
none: false
|
108
86
|
requirements:
|
109
87
|
- - "="
|
@@ -111,10 +89,10 @@ dependencies:
|
|
111
89
|
version: 0.6.7
|
112
90
|
type: :runtime
|
113
91
|
prerelease: false
|
114
|
-
version_requirements: *
|
92
|
+
version_requirements: *id007
|
115
93
|
- !ruby/object:Gem::Dependency
|
116
94
|
name: delayed_job
|
117
|
-
requirement: &
|
95
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
118
96
|
none: false
|
119
97
|
requirements:
|
120
98
|
- - ~>
|
@@ -122,18 +100,7 @@ dependencies:
|
|
122
100
|
version: 2.1.0
|
123
101
|
type: :runtime
|
124
102
|
prerelease: false
|
125
|
-
version_requirements: *
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: thoughtbot-shoulda
|
128
|
-
requirement: &id011 !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
|
-
requirements:
|
131
|
-
- - ">="
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: "0"
|
134
|
-
type: :runtime
|
135
|
-
prerelease: false
|
136
|
-
version_requirements: *id011
|
103
|
+
version_requirements: *id008
|
137
104
|
description: Extension to Delayed Job to enable workers to scale up when needed
|
138
105
|
email: paul.crabtree@gmail.com
|
139
106
|
executables: []
|
@@ -158,10 +125,9 @@ files:
|
|
158
125
|
- lib/workless/scaler.rb
|
159
126
|
- lib/workless/scalers/base.rb
|
160
127
|
- lib/workless/scalers/heroku.rb
|
128
|
+
- lib/workless/scalers/heroku_cedar.rb
|
161
129
|
- lib/workless/scalers/local.rb
|
162
130
|
- lib/workless/scalers/null.rb
|
163
|
-
- test/helper.rb
|
164
|
-
- test/test_workless.rb
|
165
131
|
- workless.gemspec
|
166
132
|
has_rdoc: true
|
167
133
|
homepage: http://github.com/lostboy/workless
|
@@ -191,6 +157,5 @@ rubygems_version: 1.5.0
|
|
191
157
|
signing_key:
|
192
158
|
specification_version: 3
|
193
159
|
summary: Use delayed job workers only when theyre needed
|
194
|
-
test_files:
|
195
|
-
|
196
|
-
- test/test_workless.rb
|
160
|
+
test_files: []
|
161
|
+
|
data/test/helper.rb
DELETED