Skip to content

Instantly share code, notes, and snippets.

@mimosz
Last active October 13, 2015 12:08
Show Gist options
  • Save mimosz/4193799 to your computer and use it in GitHub Desktop.
Save mimosz/4193799 to your computer and use it in GitHub Desktop.
Sidekiq相关
uri = [
# 运动
"http://arcteryxjrh.tmall.com",
"http://sanfo.tmall.com",
"http://skomart.tmall.com",
"http://newbalance.tmall.com",
"http://thenorthface.tmall.com",
"http://asics.tmall.com",
"http://adidas.tmall.com",
"http://salomon.tmall.com",
"http://vans.tmall.com",
"http://lining.tmall.com",
]
uri = [
# 化妆品
"http://loreal.tmall.com",
"http://marubi.tmall.com",
"http://xybc.tmall.com",
"http://nivea.tmall.com",
"http://mentholatum.tmall.com",
"http://olay.tmall.com",
]
uri = [
# 家装
'http://dulux.tmall.com',
'http://skshu.tmall.com',
'http://nipponpaint.tmall.com',
]
uri = [
# 酒
"http://jiuxian.tmall.com",
"http://jiujiajiu.tmall.com",
"http://yanghe.tmall.com",
"http://guoyujl.tmall.com",
"http://sutanjl.tmall.com",
"http://jinliufu.tmall.com",
"http://gjwjl.tmall.com",
]
uri = [
# 钻石
'http://thelovediamond.tmall.com',
'http://chowtaifook.tmall.com',
'http://chowsangsang.tmall.com',
'http://kelan.tmall.com',
'http://stonebridd.tmall.com',
]
uri = [
# 泳装
'http://xiaotao.tmall.com',
'http://chydhw.tmall.com',
'http://tinglangyd.tmall.com',
'http://sblyy.tmall.com',
'http://yiziyd.tmall.com',
'http://jgeyd.tmall.com',
]
# 创建店铺
uri.each do |url|
Seller.sync(url)
end
# 测试同步
Seller.each do |seller|
SyncWorker.perform_async(seller._id)
end
# 开启全部任务
Seller.each do |seller|
queue = { cron: '0 4 * * *', class: 'SyncWorker', args: seller._id, description: "#{seller._id} 的数据抓取。"}
Sidekiq.set_schedule("Store-#{seller.shop_id}", queue)
end
Sidekiq.reload_schedule! if Sidekiq::Scheduler.dynamic
# 关闭全部任务
Sidekiq.schedule.keys.each do |queue_id|
Sidekiq.remove_schedule(queue_id)
end
Sidekiq.reload_schedule! if Sidekiq::Scheduler.dynamic
# 队列进程启动命令
bundle exec sidekiq-scheduler -C ./config/sidekiq.yml -r ./config/boot.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment