mirror of
https://github.com/neocities/neocities.git
synced 2025-04-28 11:12:30 +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'
|
Pry.commands.alias_command 'f', 'finish'
|
||||||
end
|
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')
|
require File.join(DIR_ROOT, 'jobs', 'screenshot_job.rb')
|
||||||
|
|
||||||
Sequel.datetime_class = Time
|
Sequel.datetime_class = Time
|
||||||
|
|
|
@ -3,6 +3,8 @@ require 'RMagick'
|
||||||
|
|
||||||
class ScreenshotWorker
|
class ScreenshotWorker
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
queue :screenshots
|
||||||
|
retry 10
|
||||||
|
|
||||||
def perform(username)
|
def perform(username)
|
||||||
screenshot = Tempfile.new 'neocities_screenshot'
|
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 = Selenium::WebDriver.for :remote, url: $config['phantomjs_url'][rand($config['phantomjs_url'].length)], desired_capabilities: caps
|
||||||
driver.manage.window.resize_to 1280, 720
|
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 {
|
wait.until {
|
||||||
driver.navigate.to "http://#{username}.neocities.org"
|
driver.navigate.to "http://#{username}.neocities.org"
|
||||||
driver.save_screenshot screenshot.path
|
driver.save_screenshot screenshot.path
|
||||||
|
|
Loading…
Add table
Reference in a new issue