Sha256: 8ee77e8d731969f39ae82052252b30a1267381a7fedea142fa641c856edf1118
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
# Slight modifications from the default Resque tasks namespace :apn do task :setup task :work => :sender task :workers => :senders desc "Start an APN worker" task :sender => :setup do require 'apn' Resque.redis = ENV['REDIS'] if ENV['REDIS'] worker = nil begin worker = APN::Sender.new(:cert_path => ENV['CERT_PATH'], :environment => ENV['ENVIRONMENT'], :app => "#{ENV['APP']}_#{ENV['ENVIRONMENT']}") worker.verbose = ENV['LOGGING'] || ENV['VERBOSE'] worker.very_verbose = ENV['VVERBOSE'] rescue Exception => e raise e # abort "set QUEUE env var, e.g. $ QUEUE=critical,high rake resque:work" end puts "*** Starting worker to send apple notifications in the background from #{worker}" worker.work(ENV['INTERVAL'] || 5) # interval, will block end desc "Start multiple APN workers. Should only be used in dev mode." task :senders do threads = [] ENV['COUNT'].to_i.times do threads << Thread.new do system "rake apn:work" end end threads.each { |thread| thread.join } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sentia_apn_sender-1.0.6 | lib/apn/tasks.rb |
sentia_apn_sender-1.0.4 | lib/apn/tasks.rb |