如何在Rakefile中上传IronWorker的工作人员?

时间:2012-09-24 05:51:23

标签: ruby ironworker

我知道您可以使用IronWorker CLI工具从命令行执行此操作,但我想使用Rakefile使其更有条理,并从配置文件加载我的配置。

1 个答案:

答案 0 :(得分:2)

以下是加载本地config.yml文件的示例,使用rake workers:upload可以上传所有工作人员:

require 'uber_config'
require 'iron_worker_ng'

@config = UberConfig.load
p @config

namespace :workers do
  task :upload_email do
    client = IronWorkerNG::Client.new(@config['iron'])
    # Upload the code
    code = IronWorkerNG::Code::Base.new('workers/email_worker')
    client.codes.create(code)
  end
  task :upload_lead do
    client = IronWorkerNG::Client.new(@config['iron'])
    # Upload the code
    code = IronWorkerNG::Code::Base.new('workers/lead_worker')
    client.codes.create(code)
  end
  task :upload do
    Rake::Task["workers:upload_email"].invoke
    Rake::Task["workers:upload_lead"].invoke
  end

end