loading up the forgejo repo on tangled to test page performance
at forgejo 1.7 kB view raw
1// Copyright 2021 The Gitea Authors. All rights reserved. 2// SPDX-License-Identifier: MIT 3 4package setting 5 6import ( 7 "time" 8 9 "forgejo.org/modules/log" 10) 11 12// Mirror settings 13var Mirror = struct { 14 Enabled bool 15 DisableNewPull bool 16 DisableNewPush bool 17 DefaultInterval time.Duration 18 MinInterval time.Duration 19}{ 20 Enabled: true, 21 DisableNewPull: false, 22 DisableNewPush: false, 23 MinInterval: 10 * time.Minute, 24 DefaultInterval: 8 * time.Hour, 25} 26 27func loadMirrorFrom(rootCfg ConfigProvider) { 28 // Handle old configuration through `[repository]` `DISABLE_MIRRORS` 29 // - please note this was badly named and only disabled the creation of new pull mirrors 30 // DEPRECATED should not be removed because users maybe upgrade from lower version to the latest version 31 // if these are removed, the warning will not be shown 32 deprecatedSetting(rootCfg, "repository", "DISABLE_MIRRORS", "mirror", "ENABLED", "v1.19.0") 33 if ConfigSectionKeyBool(rootCfg.Section("repository"), "DISABLE_MIRRORS") { 34 Mirror.DisableNewPull = true 35 } 36 37 if err := rootCfg.Section("mirror").MapTo(&Mirror); err != nil { 38 log.Fatal("Failed to map Mirror settings: %v", err) 39 } 40 41 if !Mirror.Enabled { 42 Mirror.DisableNewPull = true 43 Mirror.DisableNewPush = true 44 } 45 46 if Mirror.MinInterval.Minutes() < 1 { 47 log.Warn("Mirror.MinInterval is too low, set to 1 minute") 48 Mirror.MinInterval = 1 * time.Minute 49 } 50 if Mirror.DefaultInterval < Mirror.MinInterval { 51 if time.Hour*8 < Mirror.MinInterval { 52 Mirror.DefaultInterval = Mirror.MinInterval 53 } else { 54 Mirror.DefaultInterval = time.Hour * 8 55 } 56 log.Warn("Mirror.DefaultInterval is less than Mirror.MinInterval, set to %s", Mirror.DefaultInterval.String()) 57 } 58}