mirror of
https://github.com/karust/openserp.git
synced 2026-08-05 16:53:54 +08:00
Fix config argument, update deault config.
This commit is contained in:
@@ -16,8 +16,10 @@ RUN go build -o /app/openserp .
|
||||
|
||||
FROM zenika/alpine-chrome:with-chromedriver
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY --from=builder /app/openserp /usr/local/bin/openserp
|
||||
ADD config.yaml /usr/src/app
|
||||
COPY config.yaml ./config.yaml
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:7000/health || exit 1
|
||||
|
||||
21
cmd/root.go
21
cmd/root.go
@@ -2,6 +2,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -13,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
version = "0.5.10"
|
||||
version = "0.6.0"
|
||||
defaultConfigFilename = "config"
|
||||
envPrefix = "OPENSERP"
|
||||
)
|
||||
@@ -172,13 +173,25 @@ func initializeConfig(cmd *cobra.Command) error {
|
||||
v := viper.New()
|
||||
setConfigDefaults(v)
|
||||
|
||||
// Base name of the config file, without the file extension
|
||||
v.SetConfigName(defaultConfigFilename)
|
||||
v.AddConfigPath(".")
|
||||
explicitConfigPath := strings.TrimSpace(cmd.Flag("config").Value.String())
|
||||
if explicitConfigPath == "" {
|
||||
explicitConfigPath = strings.TrimSpace(os.Getenv(envPrefix + "_SERVER_CONFIG_PATH"))
|
||||
}
|
||||
|
||||
if explicitConfigPath != "" {
|
||||
v.SetConfigFile(explicitConfigPath)
|
||||
} else {
|
||||
// Base name of the config file, without the file extension
|
||||
v.SetConfigName(defaultConfigFilename)
|
||||
v.AddConfigPath(".")
|
||||
}
|
||||
|
||||
// 1. Config file (lowest priority). Return an error if we cannot parse the config file.
|
||||
err := v.ReadInConfig()
|
||||
if err != nil {
|
||||
if explicitConfigPath != "" {
|
||||
return fmt.Errorf("cannot read config %q: %w", explicitConfigPath, err)
|
||||
}
|
||||
err = fmt.Errorf("cannot read config: %v", err)
|
||||
logrus.Warn(err)
|
||||
}
|
||||
|
||||
15
config.yaml
15
config.yaml
@@ -17,14 +17,14 @@ app:
|
||||
proxies:
|
||||
# Force a single proxy for all engines.
|
||||
# Same behavior as passing --proxy on the CLI.
|
||||
#global: socks5h://127.0.0.1:19080
|
||||
#global: http://127.0.0.1:8080
|
||||
|
||||
# Advanced mode: define tagged proxy pools and opt engines in with `proxy: <tag>`.
|
||||
entries:
|
||||
- url: http://test:test@127.0.0.1:18888
|
||||
tags: [default, us]
|
||||
- url: socks5://127.0.0.1:19080 # Browser mode fails fast on authenticated SOCKS proxies
|
||||
tags: [default, eu]
|
||||
#entries:
|
||||
# - url: http://127.0.0.1:8080
|
||||
# tags: [default, us]
|
||||
# - url: socks5h://127.0.0.1:1080
|
||||
# tags: [eu]
|
||||
health:
|
||||
failure_threshold: 3 # Disable proxy after this many consecutive failures
|
||||
|
||||
@@ -55,12 +55,10 @@ google:
|
||||
rate_requests: 4 # Allowed average requests per minute
|
||||
rate_burst: 2 # Burst requests before limiter applies
|
||||
captcha: true # Enable captcha solver path
|
||||
proxy: us
|
||||
|
||||
yandex:
|
||||
rate_requests: 4
|
||||
rate_burst: 2
|
||||
proxy: eu
|
||||
|
||||
baidu:
|
||||
rate_requests: 4
|
||||
@@ -75,4 +73,3 @@ bing:
|
||||
duckduckgo:
|
||||
rate_requests: 4
|
||||
rate_burst: 2
|
||||
proxy: default
|
||||
|
||||
@@ -9,10 +9,10 @@ services:
|
||||
- 7000:7000
|
||||
command: serve -l
|
||||
#volumes:
|
||||
# - ./config.yaml:/usr/src/app/config.yaml
|
||||
# - ./config.yaml:/usr/src/app/config.yaml:ro
|
||||
environment:
|
||||
OPENSERP_APP_HOST: "0.0.0.0"
|
||||
OPENSERP_APP_PORT: 7000
|
||||
OPENSERP_SERVER_HOST: "0.0.0.0"
|
||||
OPENSERP_SERVER_PORT: 7000
|
||||
OPENSERP_BAIDU_RATE_REQUESTS: 6 # Number of requests per Minute
|
||||
OPENSERP_BAIDU_RATE_BURST: 2 # Number of non-ratelimited requests per Minute
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user