resque 1.8.1 → 1.8.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of resque might be problematic. Click here for more details.
- data/lib/resque/version.rb +1 -1
- data/tasks/redis.rake +159 -0
- data/tasks/resque.rake +2 -0
- metadata +5 -3
data/lib/resque/version.rb
CHANGED
data/tasks/redis.rake
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
# Inspired by rabbitmq.rake the Redbox project at http://github.com/rick/redbox/tree/master
|
2
|
+
require 'fileutils'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
class RedisRunner
|
7
|
+
|
8
|
+
def self.redis_dir
|
9
|
+
@redis_dir ||= if ENV['PREFIX']
|
10
|
+
Pathname.new(ENV['PREFIX'])
|
11
|
+
else
|
12
|
+
Pathname.new(`which redis-server`) + '..' + '..'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.bin_dir
|
17
|
+
redis_dir + 'bin'
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.config
|
21
|
+
@config ||= if File.exists?(redis_dir + 'etc/redis.conf')
|
22
|
+
redis_dir + 'etc/redis.conf'
|
23
|
+
else
|
24
|
+
redis_dir + '../etc/redis.conf'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.dtach_socket
|
29
|
+
'/tmp/redis.dtach'
|
30
|
+
end
|
31
|
+
|
32
|
+
# Just check for existance of dtach socket
|
33
|
+
def self.running?
|
34
|
+
File.exists? dtach_socket
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.start
|
38
|
+
puts 'Detach with Ctrl+\ Re-attach with rake redis:attach'
|
39
|
+
sleep 1
|
40
|
+
command = "#{bin_dir}/dtach -A #{dtach_socket} #{bin_dir}/redis-server #{config}"
|
41
|
+
sh command
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.attach
|
45
|
+
exec "#{bin_dir}/dtach -a #{dtach_socket}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.stop
|
49
|
+
sh 'echo "SHUTDOWN" | nc localhost 6379'
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
namespace :redis do
|
55
|
+
|
56
|
+
desc 'About redis'
|
57
|
+
task :about do
|
58
|
+
puts "\nSee http://code.google.com/p/redis/ for information about redis.\n\n"
|
59
|
+
end
|
60
|
+
|
61
|
+
desc 'Start redis'
|
62
|
+
task :start do
|
63
|
+
RedisRunner.start
|
64
|
+
end
|
65
|
+
|
66
|
+
desc 'Stop redis'
|
67
|
+
task :stop do
|
68
|
+
RedisRunner.stop
|
69
|
+
end
|
70
|
+
|
71
|
+
desc 'Restart redis'
|
72
|
+
task :restart do
|
73
|
+
RedisRunner.stop
|
74
|
+
RedisRunner.start
|
75
|
+
end
|
76
|
+
|
77
|
+
desc 'Attach to redis dtach socket'
|
78
|
+
task :attach do
|
79
|
+
RedisRunner.attach
|
80
|
+
end
|
81
|
+
|
82
|
+
desc 'Install the latest verison of Redis from Github (requires git, duh)'
|
83
|
+
task :install => [:about, :download, :make] do
|
84
|
+
bin_dir = '/usr/bin'
|
85
|
+
conf_dir = '/etc'
|
86
|
+
|
87
|
+
if ENV['PREFIX']
|
88
|
+
bin_dir = "#{ENV['PREFIX']}/bin"
|
89
|
+
sh "mkdir -p #{bin_dir}" unless File.exists?("#{bin_dir}")
|
90
|
+
|
91
|
+
conf_dir = "#{ENV['PREFIX']}/etc"
|
92
|
+
sh "mkdir -p #{conf_dir}" unless File.exists?("#{conf_dir}")
|
93
|
+
end
|
94
|
+
|
95
|
+
%w(redis-benchmark redis-cli redis-server).each do |bin|
|
96
|
+
sh "cp /tmp/redis/#{bin} #{bin_dir}"
|
97
|
+
end
|
98
|
+
|
99
|
+
puts "Installed redis-benchmark, redis-cli and redis-server to #{bin_dir}"
|
100
|
+
|
101
|
+
unless File.exists?("#{conf_dir}/redis.conf")
|
102
|
+
sh "cp /tmp/redis/redis.conf #{conf_dir}/redis.conf"
|
103
|
+
puts "Installed redis.conf to #{conf_dir} \n You should look at this file!"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
task :make do
|
108
|
+
sh "cd /tmp/redis && make clean"
|
109
|
+
sh "cd /tmp/redis && make"
|
110
|
+
end
|
111
|
+
|
112
|
+
desc "Download package"
|
113
|
+
task :download do
|
114
|
+
sh 'rm -rf /tmp/redis/' if File.exists?("/tmp/redis/.svn")
|
115
|
+
sh 'git clone git://github.com/antirez/redis.git /tmp/redis' unless File.exists?('/tmp/redis')
|
116
|
+
sh "cd /tmp/redis && git pull" if File.exists?("/tmp/redis/.git")
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
namespace :dtach do
|
122
|
+
|
123
|
+
desc 'About dtach'
|
124
|
+
task :about do
|
125
|
+
puts "\nSee http://dtach.sourceforge.net/ for information about dtach.\n\n"
|
126
|
+
end
|
127
|
+
|
128
|
+
desc 'Install dtach 0.8 from source'
|
129
|
+
task :install => [:about, :download, :make] do
|
130
|
+
|
131
|
+
bin_dir = "/usr/bin"
|
132
|
+
|
133
|
+
if ENV['PREFIX']
|
134
|
+
bin_dir = "#{ENV['PREFIX']}/bin"
|
135
|
+
sh "mkdir -p #{bin_dir}" unless File.exists?("#{bin_dir}")
|
136
|
+
end
|
137
|
+
|
138
|
+
sh "cp /tmp/dtach-0.8/dtach #{bin_dir}"
|
139
|
+
end
|
140
|
+
|
141
|
+
task :make do
|
142
|
+
sh 'cd /tmp/dtach-0.8/ && ./configure && make'
|
143
|
+
end
|
144
|
+
|
145
|
+
desc "Download package"
|
146
|
+
task :download do
|
147
|
+
unless File.exists?('/tmp/dtach-0.8.tar.gz')
|
148
|
+
require 'net/http'
|
149
|
+
|
150
|
+
url = 'http://downloads.sourceforge.net/project/dtach/dtach/0.8/dtach-0.8.tar.gz'
|
151
|
+
open('/tmp/dtach-0.8.tar.gz', 'wb') do |file| file.write(open(url).read) end
|
152
|
+
end
|
153
|
+
|
154
|
+
unless File.directory?('/tmp/dtach-0.8')
|
155
|
+
sh 'cd /tmp && tar xzf dtach-0.8.tar.gz'
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
data/tasks/resque.rake
ADDED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 8
|
8
|
-
-
|
9
|
-
version: 1.8.
|
8
|
+
- 2
|
9
|
+
version: 1.8.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Chris Wanstrath
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-03 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -128,6 +128,8 @@ files:
|
|
128
128
|
- test/resque_test.rb
|
129
129
|
- test/test_helper.rb
|
130
130
|
- test/worker_test.rb
|
131
|
+
- tasks/redis.rake
|
132
|
+
- tasks/resque.rake
|
131
133
|
has_rdoc: true
|
132
134
|
homepage: http://github.com/defunkt/mustache
|
133
135
|
licenses: []
|