resque 1.2.1 → 1.2.3

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/HISTORY.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 1.2.3 (2009-12-15)
2
+
3
+ * Bugfix: Fixed `rand` seeding in child processes.
4
+ * Bugfix: Better JSON encoding/decoding without Yajl.
5
+ * Bugfix: Avoid `ps` flag error on Linux
6
+ * Add `PREFIX` observance to `rake` install tasks.
7
+
8
+ ## 1.2.2 (2009-12-08)
9
+
10
+ * Bugfix: Job equality was not properly implemented.
11
+
1
12
  ## 1.2.1 (2009-12-07)
2
13
 
3
14
  * Added `rake resque:workers` task for starting multiple workers.
@@ -497,6 +497,13 @@ install and run Redis for you:
497
497
  $ rake redis:install dtach:install
498
498
  $ rake redis:start
499
499
 
500
+ Or, if you don't have admin access on your machine:
501
+
502
+ $ git clone git://github.com/defunkt/resque.git
503
+ $ cd resque
504
+ $ PREFIX=<your_prefix> rake redis:install dtach:install
505
+ $ rake redis:start
506
+
500
507
  You now have Redis running on 6379. Wait a second then hit ctrl-\ to
501
508
  detach and keep it running in the background.
502
509
 
@@ -507,7 +514,7 @@ together. But, it's not that hard.
507
514
  Resque Dependencies
508
515
  -------------------
509
516
 
510
- gem install redis redis-namespace yajl-ruby --source=http://gemcutter.org
517
+ gem install redis redis-namespace yajl-ruby
511
518
 
512
519
  If you cannot install `yajl-ruby` (JRuby?), you can install the `json`
513
520
  gem and Resque will use it instead.
@@ -520,7 +527,7 @@ Installing Resque
520
527
 
521
528
  First install the gem.
522
529
 
523
- $ gem install resque --source=http://gemcutter.org
530
+ $ gem install resque
524
531
 
525
532
  Next include it in your application.
526
533
 
@@ -550,7 +557,7 @@ don't want to load your app every time rake runs.
550
557
 
551
558
  First install the gem.
552
559
 
553
- $ gem install resque --source=http://gemcutter.org
560
+ $ gem install resque
554
561
 
555
562
  Next include it in your application.
556
563
 
@@ -102,8 +102,6 @@ module Resque
102
102
 
103
103
  # Given a queue name, completely deletes the queue.
104
104
  def remove_queue(queue)
105
- @watched_queues ||= {}
106
- @watched_queues.delete(queue.to_s)
107
105
  redis.srem(:queues, queue.to_s)
108
106
  redis.del("queue:#{queue}")
109
107
  end
@@ -111,8 +109,6 @@ module Resque
111
109
  # Used internally to keep track of which queues we've created.
112
110
  # Don't call this directly.
113
111
  def watch_queue(queue)
114
- @watched_queues ||= {}
115
- return if @watched_queues[queue]
116
112
  redis.sadd(:queues, queue.to_s)
117
113
  end
118
114
 
@@ -12,7 +12,7 @@ module Resque
12
12
  if defined? Yajl
13
13
  Yajl::Encoder.encode(object)
14
14
  else
15
- JSON(object)
15
+ object.to_json
16
16
  end
17
17
  end
18
18
 
@@ -23,7 +23,7 @@ module Resque
23
23
  if defined? Yajl
24
24
  Yajl::Parser.parse(object, :check_utf8 => false)
25
25
  else
26
- JSON(object)
26
+ JSON.parse(object)
27
27
  end
28
28
  end
29
29
 
@@ -96,7 +96,7 @@ module Resque
96
96
  # Equality
97
97
  def ==(other)
98
98
  queue == other.queue &&
99
- payload_class = other.payload_class &&
99
+ payload_class == other.payload_class &&
100
100
  args == other.args
101
101
  end
102
102
  end
@@ -1,3 +1,3 @@
1
1
  module Resque
2
- Version = '1.2.1'
2
+ Version = '1.2.3'
3
3
  end
@@ -114,6 +114,7 @@ module Resque
114
114
  log "got: #{job.inspect}"
115
115
 
116
116
  if @child = fork
117
+ rand # Reseeding
117
118
  procline = "resque: Forked #{@child} at #{Time.now.to_i}"
118
119
  $0 = procline
119
120
  log! procline
@@ -245,7 +246,7 @@ module Resque
245
246
  def kill_child
246
247
  if @child
247
248
  log! "Killing child at #{@child}"
248
- if system("ps -ho pid,state -p #{@child}")
249
+ if system("ps -o pid,state -p #{@child}")
249
250
  Process.kill("KILL", @child) rescue nil
250
251
  else
251
252
  log! "Child #{@child} not found, restarting."
@@ -9,7 +9,12 @@ class RedisRunner
9
9
  end
10
10
 
11
11
  def self.redisconfdir
12
- '/etc/redis.conf'
12
+ server_dir = File.dirname(`which redis-server`)
13
+ conf_file = "#{server_dir}/../etc/redis.conf"
14
+ unless File.exists? conf_file
15
+ conf_file = "#{server_dir}/../../etc/redis.conf"
16
+ end
17
+ conf_file
13
18
  end
14
19
 
15
20
  def self.dtach_socket
@@ -65,17 +70,19 @@ namespace :redis do
65
70
  RedisRunner.attach
66
71
  end
67
72
 
68
- desc 'Install the lastest verison of Redis from Github (requires git, duh)'
73
+ desc 'Install the latest verison of Redis from Github (requires git, duh)'
69
74
  task :install => [:about, :download, :make] do
75
+ ENV['PREFIX'] and bin_dir = "#{ENV['PREFIX']}/bin" or bin_dir = '/usr/bin'
70
76
  %w(redis-benchmark redis-cli redis-server).each do |bin|
71
- sh "sudo cp /tmp/redis/#{bin} /usr/bin/"
77
+ sh "cp /tmp/redis/#{bin} #{bin_dir}"
72
78
  end
73
79
 
74
- puts "Installed redis-benchmark, redis-cli and redis-server to /usr/bin/"
80
+ puts "Installed redis-benchmark, redis-cli and redis-server to #{bin_dir}"
75
81
 
76
- unless File.exists?('/etc/redis.conf')
77
- sh 'sudo cp /tmp/redis/redis.conf /etc/'
78
- puts "Installed redis.conf to /etc/ \n You should look at this file!"
82
+ ENV['PREFIX'] and conf_dir = "#{ENV['PREFIX']}/etc" or conf_dir = '/etc'
83
+ unless File.exists?("#{conf_dir}")
84
+ sh "cp /tmp/redis/redis.conf #{conf_dir}"
85
+ puts "Installed redis.conf to #{conf_dir} \n You should look at this file!"
79
86
  end
80
87
  end
81
88
 
@@ -115,11 +122,12 @@ namespace :dtach do
115
122
  system('tar xzf dtach-0.8.tar.gz')
116
123
  end
117
124
 
125
+ ENV['PREFIX'] and bin_dir = "#{ENV['PREFIX']}/bin" or bin_dir = "/usr/bin"
118
126
  Dir.chdir('/tmp/dtach-0.8/')
119
127
  sh 'cd /tmp/dtach-0.8/ && ./configure && make'
120
- sh 'sudo cp /tmp/dtach-0.8/dtach /usr/bin/'
128
+ sh "cp /tmp/dtach-0.8/dtach #{bin_dir}"
121
129
 
122
- puts 'Dtach successfully installed to /usr/bin.'
130
+ puts "Dtach successfully installed to #{bin_dir}"
123
131
  end
124
132
  end
125
133
 
@@ -59,8 +59,15 @@ context "Resque" do
59
59
  test "jobs can test for equality" do
60
60
  assert Resque::Job.create(:jobs, 'SomeJob', 20, '/tmp')
61
61
  assert Resque::Job.create(:jobs, 'some-job', 20, '/tmp')
62
- job = Resque.reserve(:jobs)
63
- assert_equal job, Resque.reserve(:jobs)
62
+ assert_equal Resque.reserve(:jobs), Resque.reserve(:jobs)
63
+
64
+ assert Resque::Job.create(:jobs, 'SomeMethodJob', 20, '/tmp')
65
+ assert Resque::Job.create(:jobs, 'SomeJob', 20, '/tmp')
66
+ assert_not_equal Resque.reserve(:jobs), Resque.reserve(:jobs)
67
+
68
+ assert Resque::Job.create(:jobs, 'SomeJob', 20, '/tmp')
69
+ assert Resque::Job.create(:jobs, 'SomeJob', 30, '/tmp')
70
+ assert_not_equal Resque.reserve(:jobs), Resque.reserve(:jobs)
64
71
  end
65
72
 
66
73
  test "can put jobs on a queue by way of a method" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-07 00:00:00 -08:00
12
+ date: 2009-12-15 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency