Sha256: a04c91be15c7cffbe1c9f36330a6a917ea86d5ddbbe9f634636e1dcf8beeed86

Contents?: true

Size: 1.55 KB

Versions: 19

Compression:

Stored size: 1.55 KB

Contents

if File.exists? Rails.root.join('config/initializers/resque.rb')
  namespace :resque do
    require Rails.root.join('config/initializers/resque.rb')
    require 'resque/tasks'
    if defined?(Resque::Scheduler)
      require 'resque_scheduler/tasks'
    end
    
    task :setup => :environment

    task :_work => ['resque:preload', 'resque:setup'] do
      work = Resque::Worker.new('*')
      Process.daemon(true)
      File.open(Rails.root.join('tmp/resque.pid'), 'w') { |f| f << work.pid }
      work.work(5)
    end

    if defined?(Resque::Scheduler)
      task :_scheduler => 'resque:setup' do
        Process.daemon(true)
        File.open(Rails.root.join('tmp/scheduler.pid'), 'w') { |f| f << Process.pid.to_s }
        Resque::Scheduler.run
      end
    end

    desc 'Start Resque daemon worker'
    task :start => 'resque:stop' do
      zfben_rails_rake_system "bash -c 'RAILS_ENV=production rake resque:_work'"
      if defined?(Resque::Scheduler)
        zfben_rails_rake_system "bash -c 'RAILS_ENV=production rake resque:_scheduler'"
      end
    end

    desc 'Stop Resque worker'
    task :stop do
      ['resque', 'scheduler'].each do |name|
        path = Rails.root.join('tmp/' + name + '.pid')
        if File.exists?(path)
          zfben_rails_rake_system "kill `cat #{path}`;rm #{path}"
        end
      end
    end

    desc 'Clear Resque data'
    task :clear do
      Resque.redis.keys('*').each{ |k| Resque.redis.del k }
    end

    desc 'Start Resque web interface'
    task :web do
      require 'resque/server'
      Resque::Server.run!
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
h2ocube_rails_tasks-0.0.14 lib/h2ocube_rails_tasks/tasks/resque.rb
h2ocube_rails_tasks-0.0.13 lib/h2ocube_rails_tasks/tasks/resque.rb
h2ocube_rails_tasks-0.0.12 lib/h2ocube_rails_tasks/tasks/resque.rb
h2ocube_rails_tasks-0.0.11 lib/h2ocube_rails_tasks/tasks/resque.rb
h2ocube_rails_tasks-0.0.10 lib/h2ocube_rails_tasks/tasks/resque.rb
h2ocube_rails_tasks-0.0.9 lib/h2ocube_rails_tasks/tasks/resque.rb
h2ocube_rails_tasks-0.0.8 lib/h2ocube_rails_tasks/tasks/resque.rb
h2ocube_rails_tasks-0.0.7 lib/h2ocube_rails_tasks/tasks/resque.rb
h2ocube_rails_tasks-0.0.6 lib/h2ocube_rails_tasks/tasks/resque.rb
h2ocube_rails_tasks-0.0.5 lib/h2ocube_rails_tasks/tasks/resque.rb
h2ocube_rails_tasks-0.0.4 lib/h2ocube_rails_tasks/tasks/resque.rb
h2ocube_rails_tasks-0.0.3 lib/h2ocube_rails_tasks/tasks/resque.rb
h2ocube_rails_tasks-0.0.2 lib/h2ocube_rails_tasks/tasks/resque.rb
h2ocube_rails_tasks-0.0.1 lib/h2ocube_rails_tasks/tasks/resque.rb
zfben_rails_rake-0.0.23 lib/zfben_rails_rake/tasks/resque.rb
zfben_rails_rake-0.0.22 lib/zfben_rails_rake/tasks/resque.rb
zfben_rails_rake-0.0.21 lib/zfben_rails_rake/tasks/resque.rb
zfben_rails_rake-0.0.20 lib/zfben_rails_rake/tasks/resque.rb
zfben_rails_rake-0.0.19 lib/zfben_rails_rake/tasks/resque.rb