mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
queue, retry, config
This commit is contained in:
parent
91b4d8aa14
commit
93ede044d9
2 changed files with 11 additions and 1 deletions
|
@ -25,6 +25,14 @@ if defined?(Pry)
|
|||
Pry.commands.alias_command 'f', 'finish'
|
||||
end
|
||||
|
||||
Sidekiq.configure_server do |config|
|
||||
config.redis = { namespace: 'neocitiesworker' }
|
||||
end
|
||||
|
||||
Sidekiq.configure_client do |config|
|
||||
config.redis = { namespace: 'neocitiesworker' }
|
||||
end
|
||||
|
||||
require File.join(DIR_ROOT, 'jobs', 'screenshot_job.rb')
|
||||
|
||||
Sequel.datetime_class = Time
|
||||
|
|
|
@ -3,6 +3,8 @@ require 'RMagick'
|
|||
|
||||
class ScreenshotWorker
|
||||
include Sidekiq::Worker
|
||||
queue :screenshots
|
||||
retry 10
|
||||
|
||||
def perform(username)
|
||||
screenshot = Tempfile.new 'neocities_screenshot'
|
||||
|
@ -13,7 +15,7 @@ class ScreenshotWorker
|
|||
driver = Selenium::WebDriver.for :remote, url: $config['phantomjs_url'][rand($config['phantomjs_url'].length)], desired_capabilities: caps
|
||||
driver.manage.window.resize_to 1280, 720
|
||||
|
||||
wait = Selenium::WebDriver::Wait.new(:timeout => 30) # seconds
|
||||
wait = Selenium::WebDriver::Wait.new(timeout: 30) # seconds
|
||||
wait.until {
|
||||
driver.navigate.to "http://#{username}.neocities.org"
|
||||
driver.save_screenshot screenshot.path
|
||||
|
|
Loading…
Add table
Reference in a new issue