add domain index, check uri on screenshots, set workers to system cpu core count

This commit is contained in:
Kyle Drake 2023-03-22 13:37:18 +00:00
parent ea927551ef
commit f109b416a0
3 changed files with 14 additions and 3 deletions

View file

@ -0,0 +1,9 @@
Sequel.migration do
up {
DB.add_index :sites, :domain
}
down {
DB.drop_index :sites, :domain
}
end

View file

@ -7,8 +7,7 @@ environment 'production'
pidfile '/var/run/neocities/neocities.pid'
stdout_redirect '/var/log/neocities/neocities.stdout.log', '/var/log/neocities/neocities.stderr.log', true
quiet
workers 8
#workers Facter.value('processors')['count']
workers Facter.value('processors')['count']
preload_app!
on_worker_boot { DB.disconnect }
bind 'unix:/var/run/neocities/neocities.sock?backlog=2048'

View file

@ -45,7 +45,10 @@ class ScreenshotWorker
begin
base_image_tmpfile_path = "/tmp/#{SecureRandom.uuid}.png"
File.write base_image_tmpfile_path, HTTP.basic_auth(user: api_user, pass: api_password).get(uri).to_s
http_resp = HTTP.basic_auth(user: api_user, pass: api_password).get(uri)
BlackBox.new(site, path).check_uri(http_resp.headers['X-URL'])
File.write base_image_tmpfile_path, http_resp.to_s
user_screenshots_path = File.join SCREENSHOTS_PATH, Site.sharding_dir(username), username
screenshot_path = File.join user_screenshots_path, File.dirname(path_for_screenshot)