我知道您可以使用IronWorker CLI工具从命令行执行此操作,但我想使用Rakefile使其更有条理,并从配置文件加载我的配置。
答案 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