From e8c7ff3d7f5e6ffb35836a378699798832ec285c Mon Sep 17 00:00:00 2001 From: zyx Date: Mon, 25 May 2020 18:08:31 +0800 Subject: [PATCH] config items of timeout --- worker/config.go | 2 ++ worker/config_test.go | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/worker/config.go b/worker/config.go index f141fb7..5aac00e 100644 --- a/worker/config.go +++ b/worker/config.go @@ -53,6 +53,7 @@ type globalConfig struct { Concurrent int `toml:"concurrent"` Interval int `toml:"interval"` Retry int `toml:"retry"` + Timeout int `toml:"timeout"` ExecOnSuccess []string `toml:"exec_on_success"` ExecOnFailure []string `toml:"exec_on_failure"` @@ -118,6 +119,7 @@ type mirrorConfig struct { Upstream string `toml:"upstream"` Interval int `toml:"interval"` Retry int `toml:"retry"` + Timeout int `toml:"timeout"` MirrorDir string `toml:"mirror_dir"` MirrorSubDir string `toml:"mirror_subdir"` LogDir string `toml:"log_dir"` diff --git a/worker/config_test.go b/worker/config_test.go index 4114097..4386086 100644 --- a/worker/config_test.go +++ b/worker/config_test.go @@ -19,6 +19,7 @@ mirror_dir = "/data/mirrors" concurrent = 10 interval = 240 retry = 3 +timeout = 86400 [manager] api_base = "https://127.0.0.1:5000" @@ -37,6 +38,7 @@ provider = "command" upstream = "https://aosp.google.com/" interval = 720 retry = 2 +timeout = 3600 mirror_dir = "/data/git/AOSP" exec_on_success = [ "bash -c 'echo ${TUNASYNC_JOB_EXIT_STATUS} > ${TUNASYNC_WORKING_DIR}/exit_status'" @@ -119,6 +121,7 @@ use_ipv6 = true So(cfg.Global.Name, ShouldEqual, "test_worker") So(cfg.Global.Interval, ShouldEqual, 240) So(cfg.Global.Retry, ShouldEqual, 3) + So(cfg.Global.Timeout, ShouldEqual, 86400) So(cfg.Global.MirrorDir, ShouldEqual, "/data/mirrors") So(cfg.Manager.APIBase, ShouldEqual, "https://127.0.0.1:5000") @@ -130,12 +133,14 @@ use_ipv6 = true So(m.Provider, ShouldEqual, provCommand) So(m.Interval, ShouldEqual, 720) So(m.Retry, ShouldEqual, 2) + So(m.Timeout, ShouldEqual, 3600) So(m.Env["REPO"], ShouldEqual, "/usr/local/bin/aosp-repo") m = cfg.Mirrors[1] So(m.Name, ShouldEqual, "debian") So(m.MirrorDir, ShouldEqual, "") So(m.Provider, ShouldEqual, provTwoStageRsync) + So(m.Timeout, ShouldEqual, 86400) m = cfg.Mirrors[2] So(m.Name, ShouldEqual, "fedora")