2

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

4

1 回答 1

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
于 2012-09-24T05:51:23.480 回答