eycloud-recipe-resque 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -1
- data/ChangeLog.md +11 -0
- data/README.md +82 -7
- data/eycloud-recipe-resque.gemspec +1 -1
- data/libraries/find_resque_instances.rb +21 -0
- data/libraries/get_resque_worker_count.rb +3 -2
- data/metadata.json +1 -1
- data/metadata.rb +1 -1
- data/recipes/configure.rb +1 -2
- data/recipes/install.rb +1 -2
- data/recipes/restart.rb +2 -3
- metadata +10 -9
- data/Gemfile.lock +0 -18
data/.gitignore
CHANGED
data/ChangeLog.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# ChangeLog
|
2
|
+
|
3
|
+
## v1.1.0
|
4
|
+
|
5
|
+
Fixes based on testing with [todo_with_resque](https://github.com/engineyard/todo_with_resque) Rails 3 app.
|
6
|
+
|
7
|
+
Most important change: Instructions on how to restart resque after deploy!
|
8
|
+
|
9
|
+
## v1.0.0
|
10
|
+
|
11
|
+
First release based on various Resque projects found.
|
data/README.md
CHANGED
@@ -1,16 +1,26 @@
|
|
1
|
+
|
1
2
|
# Resque recipe for EY Cloud
|
2
3
|
|
3
|
-
Resque is a Redis-backed Ruby library for creating background jobs, placing those jobs on multiple queues, and processing them later.
|
4
|
+
[Resque](https://github.com/defunkt/resque) is a Redis-backed Ruby library for creating background jobs, placing those jobs on multiple queues, and processing them later.
|
4
5
|
|
5
|
-
This recipe will setup
|
6
|
+
This recipe will setup Resque on a Solo instance environment or on named Utility instances in a cluster environment.
|
6
7
|
|
7
|
-
|
8
|
+
## Installation
|
8
9
|
|
9
|
-
|
10
|
+
1. Install the recipe
|
11
|
+
2. Add a deploy hook to restart resque workers after the application restarts
|
12
|
+
3. Name all utility instances `resque`.
|
10
13
|
|
11
|
-
|
14
|
+
```ruby
|
15
|
+
# deploy/after_restart.rb
|
16
|
+
on_utilities(:resque) do
|
17
|
+
node[:applications].each do |app_name, data|
|
18
|
+
sudo 'echo "sleep 20 && monit -g resque_#{app_name} restart all" | at now'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
```
|
12
22
|
|
13
|
-
|
23
|
+
### Simple Installation
|
14
24
|
|
15
25
|
To add this recipe to your collection of recipes, or as your first recipe, you can use the helpful `ey-recipes` command line tool:
|
16
26
|
|
@@ -27,7 +37,7 @@ If you want to have your recipes run during deploy (rather than the separate `ey
|
|
27
37
|
git add .; git commit -m "added delayed job recipe"; git push origin master
|
28
38
|
ey deploy
|
29
39
|
|
30
|
-
|
40
|
+
### Manual Installation
|
31
41
|
|
32
42
|
Clone/copy this repository into a `cookbooks/resque` folder (such that you have a `cookbooks/resque/recipes/default.rb` file). This recipe must be installed as `resque` and not `eycloud-recipe-resque` or anything fancy.
|
33
43
|
|
@@ -41,3 +51,68 @@ repository.
|
|
41
51
|
Then to upload and apply to EY Cloud for a given environment:
|
42
52
|
|
43
53
|
ey recipes upload --apply -e target-environment
|
54
|
+
|
55
|
+
### Rails 3
|
56
|
+
|
57
|
+
To ensure that Resque can discover where Redis installed, create a `config/initializers/resque.rb` file:
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
resque_yml = File.expand_path('../../resque.yml', __FILE__)
|
61
|
+
if File.exist?(resque_yml)
|
62
|
+
Resque.redis = YAML.load_file(resque_yml)["redis_uri"]
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
66
|
+
## How do I get some Resque workers?
|
67
|
+
|
68
|
+
Resque workers can process 1 task/job at a time.
|
69
|
+
|
70
|
+
If you have a solo instance, then one Resque worker is provisioned.
|
71
|
+
|
72
|
+
If you have one or more app instances, then no Resque workers are provisioned. Instead, add dedicated utility instances to provision Resque workers.
|
73
|
+
|
74
|
+
Name your Utility instances `resque`.
|
75
|
+
|
76
|
+
## How many Resque workers will I get?
|
77
|
+
|
78
|
+
All the available memory of an instance is used for Resque workers, with 300Mb set aside for operating system tasks. Resque workers are allocated 300Mb each.
|
79
|
+
|
80
|
+
As above, solo instances of any time have 1 worker.
|
81
|
+
|
82
|
+
For utility instances you get approximately the following number of workers:
|
83
|
+
|
84
|
+
* Small -> 4 workers within 1.7 GB
|
85
|
+
* Large -> 24 workers within 7.5 GB
|
86
|
+
* Extra Large -> 49 workers within 15 GB
|
87
|
+
|
88
|
+
* High Memory Extra Large -> 55 workers within 17.1 GB
|
89
|
+
* High-Memory Double Extra Large -> 113 workers within 34.2 GB
|
90
|
+
* High-Memory Quadruple Extra Large -> 213 workers within 64.4 GB
|
91
|
+
|
92
|
+
* High-CPU Medium -> 4 workers within 1.7 GB
|
93
|
+
* High-CPU Extra Large -> 22 workers within 7 GB
|
94
|
+
|
95
|
+
## How do I setup Redis?
|
96
|
+
|
97
|
+
This recipe assumes that Redis is running within the environment. Fortunately, it is. Redis is automatically running on all Engine Yard Cloud environments.
|
98
|
+
|
99
|
+
If you have a dedicate Redis instance called `redis` then this recipe will discover and use that version of Redis.
|
100
|
+
|
101
|
+
## How do I use resque-web?
|
102
|
+
|
103
|
+
In a Rails 3 app, you can access "resque-web" via your normal Rails app using mounted apps.
|
104
|
+
|
105
|
+
As a very simple, moderately secure method, add the following into your `routes.rb` routes:
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
require "resque/server"
|
109
|
+
mount Resque::Server.new, :at => "/resque/34257893542"
|
110
|
+
```
|
111
|
+
|
112
|
+
For more security, consider the ideas in this [gist](https://gist.github.com/1575082).
|
113
|
+
|
114
|
+
## Helpers
|
115
|
+
|
116
|
+
* `resque_instances` - returns list of instances that have resque running on them
|
117
|
+
* `resque_instance?` - does this instance have resque running on it?
|
118
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Chef
|
2
|
+
class Recipe
|
3
|
+
# Return which instance is to have redis installed on it
|
4
|
+
# This is determind as follows:
|
5
|
+
# 1. A utility prefixed with 'resque'
|
6
|
+
# 2. A solo
|
7
|
+
# Returns array of hash of instance data, including { "id" => "i-123456", }
|
8
|
+
def resque_instances
|
9
|
+
@resque_instances ||= node[:engineyard][:environment][:instances].find do |x|
|
10
|
+
x[:role] == "solo" || node[:instance_role] == "eylocal" ||
|
11
|
+
(node[:role] == "util" && node[:name] =~ /^(resque)/)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Does this instance run resque?
|
16
|
+
def resque_instance?
|
17
|
+
node[:instance_role] == "solo" || node[:instance_role] == "eylocal" ||
|
18
|
+
(node[:instance_role] == "util" && node[:name] =~ /^(resque)/)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
class Chef
|
2
2
|
class Recipe
|
3
|
-
def get_resque_worker_count
|
3
|
+
def get_resque_worker_count
|
4
|
+
return 1 if node[:instance_role] == 'solo' || node[:instance_role] == 'eylocal'
|
5
|
+
|
4
6
|
# $ sudo cat /proc/meminfo
|
5
7
|
# MemTotal: 1759228 kB
|
6
8
|
# ...
|
@@ -11,7 +13,6 @@ class Chef
|
|
11
13
|
# in other words, if all workers on the instance are running jobs, there should
|
12
14
|
# be memory left over
|
13
15
|
result = (mem_total_mb - node[:worker_memory].to_i) / node[:worker_memory].to_i
|
14
|
-
result /= 2 if node[:instance_role] == 'solo' || node[:instance_role] == 'eylocal'
|
15
16
|
result
|
16
17
|
end
|
17
18
|
end
|
data/metadata.json
CHANGED
data/metadata.rb
CHANGED
data/recipes/configure.rb
CHANGED
@@ -3,8 +3,7 @@
|
|
3
3
|
# Recipe:: configure
|
4
4
|
#
|
5
5
|
|
6
|
-
if
|
7
|
-
(node[:instance_role] == "util" && node[:name] =~ /^(resque)/)
|
6
|
+
if resque_instance?
|
8
7
|
resque_workers_count = get_resque_worker_count()
|
9
8
|
|
10
9
|
directory "/tmp/resque_ttls" do
|
data/recipes/install.rb
CHANGED
data/recipes/restart.rb
CHANGED
@@ -3,15 +3,14 @@
|
|
3
3
|
# Recipe:: default
|
4
4
|
#
|
5
5
|
|
6
|
-
if
|
7
|
-
(node[:instance_role] == "util" && node[:name] =~ /^(resque)/)
|
6
|
+
if resque_instance?
|
8
7
|
node[:applications].each do |app_name, data|
|
9
8
|
execute "ensure-resque-is-setup-with-monit" do
|
10
9
|
command %Q{monit reload}
|
11
10
|
end
|
12
11
|
|
13
12
|
execute "restart-resque" do
|
14
|
-
command %Q{echo "sleep 20 && monit -g #{app_name}
|
13
|
+
command %Q{echo "sleep 20 && monit -g resque_#{app_name} restart all" | at now }
|
15
14
|
end
|
16
15
|
end
|
17
16
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eycloud-recipe-resque
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eycloud-helper-cronjobs
|
16
|
-
requirement: &
|
16
|
+
requirement: &70279512580460 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70279512580460
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70279512579700 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70279512579700
|
36
36
|
description: Resque for EY Cloud
|
37
37
|
email:
|
38
38
|
- drnicwilliams@gmail.com
|
@@ -42,8 +42,8 @@ extra_rdoc_files: []
|
|
42
42
|
files:
|
43
43
|
- .DS_Store
|
44
44
|
- .gitignore
|
45
|
+
- ChangeLog.md
|
45
46
|
- Gemfile
|
46
|
-
- Gemfile.lock
|
47
47
|
- README.md
|
48
48
|
- Rakefile
|
49
49
|
- attributes/default.rb
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- files/default/resque
|
52
52
|
- files/default/resque-web
|
53
53
|
- files/default/resque_kill_stale
|
54
|
+
- libraries/find_resque_instances.rb
|
54
55
|
- libraries/get_resque_worker_count.rb
|
55
56
|
- metadata.json
|
56
57
|
- metadata.rb
|
@@ -76,7 +77,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
77
|
version: '0'
|
77
78
|
segments:
|
78
79
|
- 0
|
79
|
-
hash: -
|
80
|
+
hash: -3022652905535487665
|
80
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
82
|
none: false
|
82
83
|
requirements:
|
@@ -85,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
86
|
version: '0'
|
86
87
|
segments:
|
87
88
|
- 0
|
88
|
-
hash: -
|
89
|
+
hash: -3022652905535487665
|
89
90
|
requirements: []
|
90
91
|
rubyforge_project:
|
91
92
|
rubygems_version: 1.8.17
|
data/Gemfile.lock
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
eycloud-recipe-resque (1.0.3)
|
5
|
-
eycloud-helper-cronjobs
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
eycloud-helper-cronjobs (1.0.1)
|
11
|
-
rake (0.9.2.2)
|
12
|
-
|
13
|
-
PLATFORMS
|
14
|
-
ruby
|
15
|
-
|
16
|
-
DEPENDENCIES
|
17
|
-
eycloud-recipe-resque!
|
18
|
-
rake
|