zfben_rails_rake 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,44 +1,53 @@
1
1
  if File.exists?(ROOT + '/config/initializers/resque.rb')
2
+ require ROOT + '/config/initializers/resque.rb'
3
+ require 'resque/tasks'
4
+ if defined?(Resque::Scheduler)
5
+ require 'resque_scheduler/tasks'
6
+ end
2
7
  namespace :resque do
3
- desc 'Start Resque for debug'
4
- task :debug => :environment do
5
- require ROOT + '/config/initializers/resque.rb'
6
- worker = Resque::Worker.new('*')
7
- worker.work
8
+ task :setup => :environment
9
+
10
+ task :_work => ['resque:preload', 'resque:setup'] do
11
+ work = Resque::Worker.new('*')
12
+ Process.daemon(true)
13
+ File.open(ROOT + '/tmp/resque.pid', 'w') { |f| f << work.pid }
14
+ work.work(5)
15
+ end
16
+
17
+ if defined?(Resque::Scheduler)
18
+ task :_scheduler => 'resque:setup' do
19
+ Process.daemon(true)
20
+ File.open(ROOT + '/tmp/scheduler.pid', 'w') { |f| f << Process.pid.to_s }
21
+ Resque::Scheduler.run
22
+ end
8
23
  end
9
24
 
10
25
  desc 'Start Resque daemon worker'
11
26
  task :start => 'resque:stop' do
12
- RAILS_ENV = 'production'
13
- Rake::Task[:environment].execute
14
- work = fork do
15
- worker = Resque::Worker.new('*')
16
- Process.daemon true
17
- File.open(ROOT + '/tmp/resque.pid', 'w') { |f| f << Process.pid.to_s }
18
- worker.work
27
+ sys "bash -c 'RAILS_ENV=production rake resque:_work'"
28
+ if defined?(Resque::Scheduler)
29
+ sys "bash -c 'RAILS_ENV=production rake resque:_scheduler'"
19
30
  end
20
- print "Resque worker running at #{work}\n"
21
31
  end
22
32
 
23
33
  desc 'Stop Resque worker'
24
34
  task :stop do
25
- path = ROOT + '/tmp/resque.pid'
26
- if File.exists?(path)
27
- sys "kill `cat #{path}`;rm #{path}"
35
+ ['resque', 'scheduler'].each do |name|
36
+ path = ROOT + '/tmp/' + name + '.pid'
37
+ if File.exists?(path)
38
+ sys "kill `cat #{path}`;rm #{path}"
39
+ end
28
40
  end
29
41
  end
30
42
 
31
43
  desc 'Clear Resque data'
32
44
  task :clear do
33
- require ROOT + '/config/initializers/resque.rb'
34
45
  Resque.redis.keys('*').each{ |k| Resque.redis.del k }
35
46
  end
36
47
 
37
48
  desc 'Start Resque web interface'
38
49
  task :web do
39
- require ROOT + '/config/initializers/resque.rb'
40
- require 'resque/server'
41
- Resque::Server.run!
50
+ sys "RAILS_ENV=production resque-web #{ROOT}/config/initializers/resque.rb"
42
51
  end
43
52
  end
44
53
  end
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'zfben_rails_rake'
6
- s.version = '0.0.16'
6
+ s.version = '0.0.17'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ['Ben']
9
9
  s.email = ['ben@zfben.com']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zfben_rails_rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
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: 2011-11-01 00:00:00.000000000 Z
12
+ date: 2011-11-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rainbow
16
- requirement: &20644000 !ruby/object:Gem::Requirement
16
+ requirement: &8563300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *20644000
24
+ version_requirements: *8563300
25
25
  description: ''
26
26
  email:
27
27
  - ben@zfben.com