if Rails.env.development?
  Rails.logger = Logger.new(STDOUT)
end

# this rake file is meant to hold shortcuts/helpers for starting onerous command line executions

# bundle exec rake all_jobs
task :all_jobs do
  Rake::Task['environment'].invoke

  ENV['FORK_PER_JOB'] = 'false'
  ENV['QUEUE'] = ENV['QUEUE'] || '*'

  #Resque.logger = Logger.new(STDOUT)
  #ActiveRecord::Base.logger = Logger.new(STDOUT)

  Rake::Task['resque:work'].invoke
end

# bundle exec rake audiomixer
task :audiomixer do
  Rake::Task['environment'].invoke

  ENV['FORK_PER_JOB'] = 'false'
  ENV['QUEUE'] = 'audiomixer'
  Rake::Task['resque:work'].invoke
end

# bundle exec rake icecast
task :icecast do
  Rake::Task['environment'].invoke

  ENV['FORK_PER_JOB'] = 'false'
  ENV['QUEUE'] = 'icecast'
  Rake::Task['resque:work'].invoke
end

# bundle exec rake odd_jobs
# this command is the same as used in production
task :odd_jobs do
  Rake::Task['environment'].invoke

  ENV['FORK_PER_JOB'] = 'false'
  ENV['QUEUE'] = '*,!icecast,!audiomixer'
  Rake::Task['resque:work'].invoke
end
