Amokrane
4/9/2012 - 2:56 PM

Task launcher

Task launcher

def perform
		begin
			code = IronWorkerNG::Code::Ruby.new
			code.merge_worker File.dirname(__FILE__) + '/c2dm_iron_worker.rb'
			code.merge_dir '../config'
			code.merge_gem 'activerecord'

			# Initialize the client
			client = IronWorkerNG::Client.new(:token => 'xxx', :project_id => 'xxx')
			# Upload the code
			client.codes.create(code)
			10.times do |i|
				puts "IronWorker::Queueing worker for #{i}"
				log = client.tasks.create('C2dmIronWorker', {})
				puts log
			end
		rescue => e
			STDERR.puts "IronWorker::Error #{e}"
		end
	end