document the change in format of PROXY_CHECKER_INTERVAL

clean up
This commit is contained in:
iacore
2024-09-05 17:26:50 +00:00
parent 21db4db9b0
commit 0a9d28a105
3 changed files with 7 additions and 10 deletions
+4 -7
View File
@@ -33,10 +33,9 @@ type ServerConfig struct {
RequestLimit int `env:"PIXIVFE_REQUESTLIMIT"` // if 0, request limit is disabled
ProxyServer_staging string `env:"PIXIVFE_IMAGEPROXY,overwrite"`
ProxyServer url.URL // proxy server, may contain prefix as well
ProxyServer url.URL // proxy server URL, may or may not contain authority part of the URL
ProxyCheckInterval_staging int `env:"PIXIVFE_PROXY_CHECK_INTERVAL,overwrite"`
ProxyCheckInterval time.Duration // Proxy check interval
ProxyCheckInterval time.Duration `env:"PIXIVFE_PROXY_CHECK_INTERVAL,overwrite"`
}
func (s *ServerConfig) LoadConfig() error {
@@ -49,7 +48,7 @@ func (s *ServerConfig) LoadConfig() error {
s.UserAgent = "Mozilla/5.0 (Windows NT 10.0; rv:123.0) Gecko/20100101 Firefox/123.0"
s.AcceptLanguage = "en-US,en;q=0.5"
s.ProxyServer_staging = BuiltinProxyUrl
s.ProxyCheckInterval_staging = 480
s.ProxyCheckInterval = 8 * time.Hour
// load config from from env vars
if err := envconfig.Process(context.Background(), s); err != nil {
@@ -74,9 +73,7 @@ func (s *ServerConfig) LoadConfig() error {
log.Panicf("proxy server path (%s) has cannot end in /: %s\nPixivFE does not support this now, sorry", proxyUrl.Path, proxyUrl.String())
}
}
log.Printf("Set %s to: %s\n", "proxy server", &s.ProxyServer)
s.ProxyCheckInterval = time.Duration(s.ProxyCheckInterval_staging) * time.Minute
log.Printf("Proxy server set to: %s\n", s.ProxyServer.String())
log.Printf("Proxy check interval set to: %v\n", s.ProxyCheckInterval)
return nil
-1
View File
@@ -3,5 +3,4 @@ package config
import "time"
// todo: make this configurable
const ExpiresIn = 5 * time.Minute
const ProxyCheckerTimeout = 10 * time.Second
+3 -2
View File
@@ -90,9 +90,10 @@ The value of the `Accept-Language` header used for requests to Pixiv's API. Chan
**Required**: No
**Default:** `480`
**Default:** `8h`
The interval in minutes between proxy checks. Defaults to 480 minutes (8 hours) if not set.
The interval in minutes between proxy checks. Defaults to 8 hours if not set.
Please specify this value in Go's `time.Duration` notation, e.g. `2h3m5s`.
You can disable this by setting the value to 0. Then, proxies will only be checked once at server initialization.
### `PIXIVFE_DEV`