Sha256: 775ff7cb81262835c271b42497b033f612e3c28f9c1e4ca1ff4d8a4616c17f88

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

if File.exists?(ROOT + '/config/initializers/resque.rb')
  namespace :resque do
    desc 'Start Resque for debug'
    task :debug => :environment do
      require ROOT + '/config/initializers/resque.rb'
      worker = Resque::Worker.new('*')
      worker.work
    end

    desc 'Start Resque daemon worker'
    task :start => 'resque:stop' do
      RAILS_ENV = 'production'
      Rake::Task[:environment].execute
      work = fork do
        worker = Resque::Worker.new('*')
        Process.daemon true
        File.open(ROOT + '/tmp/resque.pid', 'w') { |f| f << Process.pid.to_s }
        worker.work
      end
      print "Resque worker running at #{work}\n"
    end

    desc 'Stop Resque worker'
    task :stop do
      path = ROOT + '/tmp/resque.pid'
      if File.exists?(path)
        sys "kill `cat #{path}`;rm #{path}"
      end
    end

    desc 'Clear Resque data'
    task :clear do
      require ROOT + '/config/initializers/resque.rb'
      Resque.redis.keys('*').each{ |k| Resque.redis.del k }
    end

    desc 'Start Resque web interface'
    task :web do
      require ROOT + '/config/initializers/resque.rb'
      require 'resque/server'
      Resque::Server.run!
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zfben_rails_rake-0.0.16 lib/zfben_rails_rake/tasks/resque.rb