mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-11-16 15:27:46 +00:00
fix: retry failed requests
This commit is contained in:
parent
517c5922c5
commit
a9efa2b2f4
15 changed files with 234 additions and 81 deletions
162
Cargo.lock
generated
162
Cargo.lock
generated
|
@ -291,7 +291,7 @@ dependencies = [
|
||||||
"objc2",
|
"objc2",
|
||||||
"objc2-app-kit",
|
"objc2-app-kit",
|
||||||
"objc2-foundation",
|
"objc2-foundation",
|
||||||
"parking_lot",
|
"parking_lot 0.12.3",
|
||||||
"x11rb",
|
"x11rb",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1380,7 +1380,7 @@ dependencies = [
|
||||||
"objc2",
|
"objc2",
|
||||||
"objc2-app-kit",
|
"objc2-app-kit",
|
||||||
"objc2-foundation",
|
"objc2-foundation",
|
||||||
"parking_lot",
|
"parking_lot 0.12.3",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"pollster",
|
"pollster",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
|
@ -1584,7 +1584,7 @@ dependencies = [
|
||||||
"epaint_default_fonts",
|
"epaint_default_fonts",
|
||||||
"log",
|
"log",
|
||||||
"nohash-hasher",
|
"nohash-hasher",
|
||||||
"parking_lot",
|
"parking_lot 0.12.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1777,6 +1777,21 @@ dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures"
|
||||||
|
version = "0.3.31"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876"
|
||||||
|
dependencies = [
|
||||||
|
"futures-channel",
|
||||||
|
"futures-core",
|
||||||
|
"futures-executor",
|
||||||
|
"futures-io",
|
||||||
|
"futures-sink",
|
||||||
|
"futures-task",
|
||||||
|
"futures-util",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-channel"
|
name = "futures-channel"
|
||||||
version = "0.3.31"
|
version = "0.3.31"
|
||||||
|
@ -1784,6 +1799,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
|
checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-core",
|
"futures-core",
|
||||||
|
"futures-sink",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1792,6 +1808,17 @@ version = "0.3.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
|
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-executor"
|
||||||
|
version = "0.3.31"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"futures-task",
|
||||||
|
"futures-util",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-io"
|
name = "futures-io"
|
||||||
version = "0.3.31"
|
version = "0.3.31"
|
||||||
|
@ -1840,6 +1867,7 @@ version = "0.3.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
|
checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"futures-channel",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-io",
|
"futures-io",
|
||||||
"futures-macro",
|
"futures-macro",
|
||||||
|
@ -1878,8 +1906,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
|
"js-sys",
|
||||||
"libc",
|
"libc",
|
||||||
"wasi",
|
"wasi",
|
||||||
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2095,6 +2125,8 @@ dependencies = [
|
||||||
"readable",
|
"readable",
|
||||||
"regex",
|
"regex",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
"reqwest-middleware",
|
||||||
|
"reqwest-retry",
|
||||||
"rfd",
|
"rfd",
|
||||||
"serde",
|
"serde",
|
||||||
"serde-this-or-that",
|
"serde-this-or-that",
|
||||||
|
@ -2405,6 +2437,18 @@ dependencies = [
|
||||||
"generic-array",
|
"generic-array",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "instant"
|
||||||
|
version = "0.1.13"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "interpolate_name"
|
name = "interpolate_name"
|
||||||
version = "0.2.4"
|
version = "0.2.4"
|
||||||
|
@ -2560,7 +2604,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
|
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"windows-targets 0.48.5",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3278,6 +3322,17 @@ version = "2.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba"
|
checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parking_lot"
|
||||||
|
version = "0.11.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
|
||||||
|
dependencies = [
|
||||||
|
"instant",
|
||||||
|
"lock_api",
|
||||||
|
"parking_lot_core 0.8.6",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parking_lot"
|
name = "parking_lot"
|
||||||
version = "0.12.3"
|
version = "0.12.3"
|
||||||
|
@ -3285,7 +3340,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
|
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lock_api",
|
"lock_api",
|
||||||
"parking_lot_core",
|
"parking_lot_core 0.9.10",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parking_lot_core"
|
||||||
|
version = "0.8.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"instant",
|
||||||
|
"libc",
|
||||||
|
"redox_syscall 0.2.16",
|
||||||
|
"smallvec",
|
||||||
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3705,6 +3774,15 @@ dependencies = [
|
||||||
"windows 0.58.0",
|
"windows 0.58.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "redox_syscall"
|
||||||
|
version = "0.2.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 1.3.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
|
@ -3811,6 +3889,51 @@ dependencies = [
|
||||||
"windows-registry",
|
"windows-registry",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "reqwest-middleware"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "562ceb5a604d3f7c885a792d42c199fd8af239d0a51b2fa6a78aafa092452b04"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"async-trait",
|
||||||
|
"http",
|
||||||
|
"reqwest",
|
||||||
|
"serde",
|
||||||
|
"thiserror",
|
||||||
|
"tower-service",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "reqwest-retry"
|
||||||
|
version = "0.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a83df1aaec00176d0fabb65dea13f832d2a446ca99107afc17c5d2d4981221d0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"async-trait",
|
||||||
|
"futures",
|
||||||
|
"getrandom",
|
||||||
|
"http",
|
||||||
|
"hyper",
|
||||||
|
"parking_lot 0.11.2",
|
||||||
|
"reqwest",
|
||||||
|
"reqwest-middleware",
|
||||||
|
"retry-policies",
|
||||||
|
"tokio",
|
||||||
|
"tracing",
|
||||||
|
"wasm-timer",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "retry-policies"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5875471e6cab2871bc150ecb8c727db5113c9338cc3354dc5ee3425b6aa40a1c"
|
||||||
|
dependencies = [
|
||||||
|
"rand",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rfd"
|
name = "rfd"
|
||||||
version = "0.15.0"
|
version = "0.15.0"
|
||||||
|
@ -4888,6 +5011,21 @@ version = "0.2.95"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d"
|
checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-timer"
|
||||||
|
version = "0.2.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f"
|
||||||
|
dependencies = [
|
||||||
|
"futures",
|
||||||
|
"js-sys",
|
||||||
|
"parking_lot 0.11.2",
|
||||||
|
"pin-utils",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-futures",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wayland-backend"
|
name = "wayland-backend"
|
||||||
version = "0.3.7"
|
version = "0.3.7"
|
||||||
|
@ -5062,7 +5200,7 @@ dependencies = [
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"log",
|
"log",
|
||||||
"naga 22.1.0",
|
"naga 22.1.0",
|
||||||
"parking_lot",
|
"parking_lot 0.12.3",
|
||||||
"profiling",
|
"profiling",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
|
@ -5087,7 +5225,7 @@ dependencies = [
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"log",
|
"log",
|
||||||
"naga 23.0.0",
|
"naga 23.0.0",
|
||||||
"parking_lot",
|
"parking_lot 0.12.3",
|
||||||
"profiling",
|
"profiling",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
|
@ -5115,7 +5253,7 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"naga 22.1.0",
|
"naga 22.1.0",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"parking_lot",
|
"parking_lot 0.12.3",
|
||||||
"profiling",
|
"profiling",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
"rustc-hash 1.1.0",
|
"rustc-hash 1.1.0",
|
||||||
|
@ -5140,7 +5278,7 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"naga 23.0.0",
|
"naga 23.0.0",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"parking_lot",
|
"parking_lot 0.12.3",
|
||||||
"profiling",
|
"profiling",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
"rustc-hash 1.1.0",
|
"rustc-hash 1.1.0",
|
||||||
|
@ -5179,7 +5317,7 @@ dependencies = [
|
||||||
"ndk-sys 0.5.0+25.2.9519653",
|
"ndk-sys 0.5.0+25.2.9519653",
|
||||||
"objc",
|
"objc",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"parking_lot",
|
"parking_lot 0.12.3",
|
||||||
"profiling",
|
"profiling",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
"renderdoc-sys",
|
"renderdoc-sys",
|
||||||
|
@ -5222,7 +5360,7 @@ dependencies = [
|
||||||
"ndk-sys 0.5.0+25.2.9519653",
|
"ndk-sys 0.5.0+25.2.9519653",
|
||||||
"objc",
|
"objc",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"parking_lot",
|
"parking_lot 0.12.3",
|
||||||
"profiling",
|
"profiling",
|
||||||
"range-alloc",
|
"range-alloc",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
|
@ -5287,7 +5425,7 @@ version = "0.1.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -51,6 +51,8 @@ egui_extras = {version="0.29.1", features = ["image"] }
|
||||||
env_logger = "0.11.5"
|
env_logger = "0.11.5"
|
||||||
figment = { version = "0.10.19", features = ["toml"] }
|
figment = { version = "0.10.19", features = ["toml"] }
|
||||||
reqwest = {version = "0.12.9", default-features=false, features=["json", "rustls-tls"]}
|
reqwest = {version = "0.12.9", default-features=false, features=["json", "rustls-tls"]}
|
||||||
|
reqwest-middleware = "0.3"
|
||||||
|
reqwest-retry = "0.6"
|
||||||
image = { version = "0.25.4", features = ["png"] }
|
image = { version = "0.25.4", features = ["png"] }
|
||||||
log = "0.4.22"
|
log = "0.4.22"
|
||||||
num-format = { version = "0.4.4", default-features = false }
|
num-format = { version = "0.4.4", default-features = false }
|
||||||
|
|
|
@ -130,7 +130,7 @@ impl eframe::App for App {
|
||||||
// xvb_is_alive is not the same for bottom and for middle.
|
// xvb_is_alive is not the same for bottom and for middle.
|
||||||
// for status we don't want to enable the column when it is retrying request
|
// for status we don't want to enable the column when it is retrying request
|
||||||
// but for bottom we don't want the user to be able to start it in this case.
|
// but for bottom we don't want the user to be able to start it in this case.
|
||||||
let xvb_is_alive = xvb_state != ProcessState::Retry && xvb_state != ProcessState::Dead;
|
let xvb_is_alive = xvb_state != ProcessState::Dead;
|
||||||
self.middle_panel(
|
self.middle_panel(
|
||||||
ctx,
|
ctx,
|
||||||
frame,
|
frame,
|
||||||
|
|
|
@ -914,7 +914,7 @@ fn status_p2pool(state: ProcessState, ui: &mut Ui, size: Vec2) {
|
||||||
color = ORANGE;
|
color = ORANGE;
|
||||||
P2POOL_SYNCING
|
P2POOL_SYNCING
|
||||||
}
|
}
|
||||||
Middle | Waiting | NotMining | OfflineNodesAll | Retry => {
|
Middle | Waiting | NotMining | OfflineNodesAll => {
|
||||||
color = YELLOW;
|
color = YELLOW;
|
||||||
P2POOL_MIDDLE
|
P2POOL_MIDDLE
|
||||||
}
|
}
|
||||||
|
@ -940,7 +940,7 @@ fn status_node(state: ProcessState, ui: &mut Ui, size: Vec2) {
|
||||||
color = ORANGE;
|
color = ORANGE;
|
||||||
NODE_SYNCING
|
NODE_SYNCING
|
||||||
}
|
}
|
||||||
Middle | Waiting | NotMining | OfflineNodesAll | Retry => {
|
Middle | Waiting | NotMining | OfflineNodesAll => {
|
||||||
color = YELLOW;
|
color = YELLOW;
|
||||||
NODE_MIDDLE
|
NODE_MIDDLE
|
||||||
}
|
}
|
||||||
|
@ -967,7 +967,7 @@ fn status_xmrig(state: ProcessState, ui: &mut Ui, size: Vec2) {
|
||||||
color = ORANGE;
|
color = ORANGE;
|
||||||
XMRIG_NOT_MINING
|
XMRIG_NOT_MINING
|
||||||
}
|
}
|
||||||
Middle | Waiting | Syncing | Retry => {
|
Middle | Waiting | Syncing => {
|
||||||
color = YELLOW;
|
color = YELLOW;
|
||||||
XMRIG_MIDDLE
|
XMRIG_MIDDLE
|
||||||
}
|
}
|
||||||
|
@ -994,7 +994,7 @@ fn status_xp(state: ProcessState, ui: &mut Ui, size: Vec2) {
|
||||||
color = ORANGE;
|
color = ORANGE;
|
||||||
XMRIG_PROXY_NOT_MINING
|
XMRIG_PROXY_NOT_MINING
|
||||||
}
|
}
|
||||||
Middle | Waiting | Syncing | Retry => {
|
Middle | Waiting | Syncing => {
|
||||||
color = YELLOW;
|
color = YELLOW;
|
||||||
XMRIG_PROXY_MIDDLE
|
XMRIG_PROXY_MIDDLE
|
||||||
}
|
}
|
||||||
|
@ -1012,7 +1012,7 @@ fn status_xvb(state: ProcessState, ui: &mut Ui, size: Vec2) {
|
||||||
color = GRAY;
|
color = GRAY;
|
||||||
XVB_DEAD
|
XVB_DEAD
|
||||||
}
|
}
|
||||||
Failed | Retry => {
|
Failed => {
|
||||||
color = RED;
|
color = RED;
|
||||||
XVB_FAILED
|
XVB_FAILED
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,6 @@ impl Process {
|
||||||
self.state == ProcessState::Alive
|
self.state == ProcessState::Alive
|
||||||
|| self.state == ProcessState::Middle
|
|| self.state == ProcessState::Middle
|
||||||
|| self.state == ProcessState::Syncing
|
|| self.state == ProcessState::Syncing
|
||||||
|| self.state == ProcessState::Retry
|
|
||||||
|| self.state == ProcessState::NotMining
|
|| self.state == ProcessState::NotMining
|
||||||
|| self.state == ProcessState::OfflineNodesAll
|
|| self.state == ProcessState::OfflineNodesAll
|
||||||
}
|
}
|
||||||
|
@ -219,8 +218,6 @@ pub enum ProcessState {
|
||||||
// Only for P2Pool and XvB, ORANGE.
|
// Only for P2Pool and XvB, ORANGE.
|
||||||
// XvB: Xmrig or P2pool are not alive
|
// XvB: Xmrig or P2pool are not alive
|
||||||
Syncing,
|
Syncing,
|
||||||
// XvB: if requests for stats fail, retry state to retry every minutes
|
|
||||||
Retry,
|
|
||||||
|
|
||||||
// Only for XMRig and XvB, ORANGE.
|
// Only for XMRig and XvB, ORANGE.
|
||||||
// XvB: token or address are invalid even if syntax correct
|
// XvB: token or address are invalid even if syntax correct
|
||||||
|
|
|
@ -8,6 +8,7 @@ mod test {
|
||||||
xvb::{priv_stats::RuntimeDonationLevel, priv_stats::RuntimeMode},
|
xvb::{priv_stats::RuntimeDonationLevel, priv_stats::RuntimeMode},
|
||||||
Helper, Process, ProcessName, ProcessState,
|
Helper, Process, ProcessName, ProcessState,
|
||||||
};
|
};
|
||||||
|
use crate::miscs::client;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn get_current_shares() {
|
fn get_current_shares() {
|
||||||
|
@ -549,11 +550,11 @@ Uptime = 0h 2m 4s
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::helper::xvb::{public_stats::XvbPubStats, PubXvbApi};
|
use crate::helper::xvb::{public_stats::XvbPubStats, PubXvbApi};
|
||||||
use reqwest::Client;
|
use reqwest_middleware::ClientWithMiddleware as Client;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn public_api_deserialize() {
|
fn public_api_deserialize() {
|
||||||
let client = Client::new();
|
let client = client();
|
||||||
let new_data = thread::spawn(move || corr(&client)).join().unwrap();
|
let new_data = thread::spawn(move || corr(&client)).join().unwrap();
|
||||||
assert!(!new_data.reward_yearly.is_empty());
|
assert!(!new_data.reward_yearly.is_empty());
|
||||||
}
|
}
|
||||||
|
@ -564,7 +565,7 @@ Uptime = 0h 2m 4s
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_manual_xvb_mode() {
|
fn test_manual_xvb_mode() {
|
||||||
let client = reqwest::Client::new();
|
let client = client();
|
||||||
let pub_api = Arc::new(Mutex::new(PubXvbApi::new()));
|
let pub_api = Arc::new(Mutex::new(PubXvbApi::new()));
|
||||||
let gui_api_xvb = Arc::new(Mutex::new(PubXvbApi::new()));
|
let gui_api_xvb = Arc::new(Mutex::new(PubXvbApi::new()));
|
||||||
let gui_api_xmrig = Arc::new(Mutex::new(PubXmrigApi::new()));
|
let gui_api_xmrig = Arc::new(Mutex::new(PubXmrigApi::new()));
|
||||||
|
@ -603,7 +604,7 @@ Uptime = 0h 2m 4s
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_manual_p2pool_mode() {
|
fn test_manual_p2pool_mode() {
|
||||||
let client = reqwest::Client::new();
|
let client = client();
|
||||||
let pub_api = Arc::new(Mutex::new(PubXvbApi::new()));
|
let pub_api = Arc::new(Mutex::new(PubXvbApi::new()));
|
||||||
let gui_api_xvb = Arc::new(Mutex::new(PubXvbApi::new()));
|
let gui_api_xvb = Arc::new(Mutex::new(PubXvbApi::new()));
|
||||||
let gui_api_xmrig = Arc::new(Mutex::new(PubXmrigApi::new()));
|
let gui_api_xmrig = Arc::new(Mutex::new(PubXmrigApi::new()));
|
||||||
|
@ -642,7 +643,7 @@ Uptime = 0h 2m 4s
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_manual_donor_level_mode_donor() {
|
fn test_manual_donor_level_mode_donor() {
|
||||||
let client = reqwest::Client::new();
|
let client = client();
|
||||||
let pub_api = Arc::new(Mutex::new(PubXvbApi::new()));
|
let pub_api = Arc::new(Mutex::new(PubXvbApi::new()));
|
||||||
let gui_api_xvb = Arc::new(Mutex::new(PubXvbApi::new()));
|
let gui_api_xvb = Arc::new(Mutex::new(PubXvbApi::new()));
|
||||||
let gui_api_xmrig = Arc::new(Mutex::new(PubXmrigApi::new()));
|
let gui_api_xmrig = Arc::new(Mutex::new(PubXmrigApi::new()));
|
||||||
|
@ -686,7 +687,7 @@ Uptime = 0h 2m 4s
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_auto_mode() {
|
fn test_auto_mode() {
|
||||||
let client = reqwest::Client::new();
|
let client = client();
|
||||||
let pub_api = Arc::new(Mutex::new(PubXvbApi::new()));
|
let pub_api = Arc::new(Mutex::new(PubXvbApi::new()));
|
||||||
let gui_api_xvb = Arc::new(Mutex::new(PubXvbApi::new()));
|
let gui_api_xvb = Arc::new(Mutex::new(PubXvbApi::new()));
|
||||||
let gui_api_xmrig = Arc::new(Mutex::new(PubXmrigApi::new()));
|
let gui_api_xmrig = Arc::new(Mutex::new(PubXmrigApi::new()));
|
||||||
|
@ -747,7 +748,7 @@ Uptime = 0h 2m 4s
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_hero_mode() {
|
fn test_hero_mode() {
|
||||||
let client = reqwest::Client::new();
|
let client = client();
|
||||||
let pub_api = Arc::new(Mutex::new(PubXvbApi::new()));
|
let pub_api = Arc::new(Mutex::new(PubXvbApi::new()));
|
||||||
let gui_api_xvb = Arc::new(Mutex::new(PubXvbApi::new()));
|
let gui_api_xvb = Arc::new(Mutex::new(PubXvbApi::new()));
|
||||||
let gui_api_xmrig = Arc::new(Mutex::new(PubXmrigApi::new()));
|
let gui_api_xmrig = Arc::new(Mutex::new(PubXmrigApi::new()));
|
||||||
|
|
|
@ -3,7 +3,7 @@ use anyhow::anyhow;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use log::info;
|
use log::info;
|
||||||
use reqwest::header::AUTHORIZATION;
|
use reqwest::header::AUTHORIZATION;
|
||||||
use reqwest::Client;
|
use reqwest_middleware::ClientWithMiddleware as Client;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
|
@ -3,7 +3,7 @@ use crate::helper::xrig::update_xmrig_config;
|
||||||
use crate::helper::{arc_mut, check_died, check_user_input, sleep, sleep_end_loop, Process};
|
use crate::helper::{arc_mut, check_died, check_user_input, sleep, sleep_end_loop, Process};
|
||||||
use crate::helper::{Helper, ProcessName, ProcessSignal, ProcessState};
|
use crate::helper::{Helper, ProcessName, ProcessSignal, ProcessState};
|
||||||
use crate::helper::{PubXvbApi, XvbNode};
|
use crate::helper::{PubXvbApi, XvbNode};
|
||||||
use crate::miscs::output_console;
|
use crate::miscs::{client, output_console};
|
||||||
use crate::regex::{contains_error, contains_usepool, detect_new_node_xmrig, XMRIG_REGEX};
|
use crate::regex::{contains_error, contains_usepool, detect_new_node_xmrig, XMRIG_REGEX};
|
||||||
use crate::utils::human::HumanNumber;
|
use crate::utils::human::HumanNumber;
|
||||||
use crate::utils::sudo::SudoState;
|
use crate::utils::sudo::SudoState;
|
||||||
|
@ -13,7 +13,7 @@ use portable_pty::Child;
|
||||||
use readable::num::Unsigned;
|
use readable::num::Unsigned;
|
||||||
use readable::up::Uptime;
|
use readable::up::Uptime;
|
||||||
use reqwest::header::AUTHORIZATION;
|
use reqwest::header::AUTHORIZATION;
|
||||||
use reqwest::Client;
|
use reqwest_middleware::ClientWithMiddleware as Client;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -455,7 +455,7 @@ impl Helper {
|
||||||
let output_parse = Arc::clone(&process.lock().unwrap().output_parse);
|
let output_parse = Arc::clone(&process.lock().unwrap().output_parse);
|
||||||
let output_pub = Arc::clone(&process.lock().unwrap().output_pub);
|
let output_pub = Arc::clone(&process.lock().unwrap().output_pub);
|
||||||
|
|
||||||
let client = Client::new();
|
let client = client();
|
||||||
let start = process.lock().unwrap().start;
|
let start = process.lock().unwrap().start;
|
||||||
let api_uri = {
|
let api_uri = {
|
||||||
if !api_ip_port.ends_with('/') {
|
if !api_ip_port.ends_with('/') {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use enclose::enc;
|
use enclose::enc;
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, info, warn};
|
||||||
use reqwest::{header::AUTHORIZATION, Client};
|
use reqwest::header::AUTHORIZATION;
|
||||||
|
use reqwest_middleware::ClientWithMiddleware as Client;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -11,6 +12,7 @@ use std::{
|
||||||
};
|
};
|
||||||
use tokio::spawn;
|
use tokio::spawn;
|
||||||
|
|
||||||
|
use crate::miscs::client;
|
||||||
use crate::{
|
use crate::{
|
||||||
disk::state::Xmrig,
|
disk::state::Xmrig,
|
||||||
helper::{
|
helper::{
|
||||||
|
@ -333,7 +335,7 @@ impl Helper {
|
||||||
let api_config_xmrig = XMRIG_CONFIG_URL;
|
let api_config_xmrig = XMRIG_CONFIG_URL;
|
||||||
|
|
||||||
// set state
|
// set state
|
||||||
let client = Client::new();
|
let client = client();
|
||||||
process.lock().unwrap().state = ProcessState::NotMining;
|
process.lock().unwrap().state = ProcessState::NotMining;
|
||||||
process.lock().unwrap().signal = ProcessSignal::None;
|
process.lock().unwrap().signal = ProcessSignal::None;
|
||||||
// reset stats
|
// reset stats
|
||||||
|
|
|
@ -9,7 +9,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use reqwest::Client;
|
use reqwest_middleware::ClientWithMiddleware as Client;
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
@ -3,13 +3,13 @@ use crate::helper::xvb::algorithm::algorithm;
|
||||||
use crate::helper::xvb::priv_stats::XvbPrivStats;
|
use crate::helper::xvb::priv_stats::XvbPrivStats;
|
||||||
use crate::helper::xvb::public_stats::XvbPubStats;
|
use crate::helper::xvb::public_stats::XvbPubStats;
|
||||||
use crate::helper::{sleep_end_loop, ProcessName};
|
use crate::helper::{sleep_end_loop, ProcessName};
|
||||||
use crate::miscs::output_console;
|
use crate::miscs::{client, output_console};
|
||||||
use crate::{XMRIG_CONFIG_URL, XMRIG_PROXY_CONFIG_URL, XMRIG_PROXY_SUMMARY_URL, XMRIG_SUMMARY_URL};
|
use crate::{XMRIG_CONFIG_URL, XMRIG_PROXY_CONFIG_URL, XMRIG_PROXY_SUMMARY_URL, XMRIG_SUMMARY_URL};
|
||||||
use bounded_vec_deque::BoundedVecDeque;
|
use bounded_vec_deque::BoundedVecDeque;
|
||||||
use enclose::enc;
|
use enclose::enc;
|
||||||
use log::{debug, info, warn};
|
use log::{debug, info, warn};
|
||||||
use readable::up::Uptime;
|
use readable::up::Uptime;
|
||||||
use reqwest::Client;
|
use reqwest_middleware::ClientWithMiddleware as Client;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -162,8 +162,7 @@ impl Helper {
|
||||||
process_xp: &Arc<Mutex<Process>>,
|
process_xp: &Arc<Mutex<Process>>,
|
||||||
) {
|
) {
|
||||||
// create uniq client that is going to be used for during the life of the thread.
|
// create uniq client that is going to be used for during the life of the thread.
|
||||||
let client = reqwest::Client::new();
|
let client = client();
|
||||||
|
|
||||||
// checks confition to start XvB, will set proper state of XvB.
|
// checks confition to start XvB, will set proper state of XvB.
|
||||||
// if state is middle (everything fine here),set which xvb node could be used.
|
// if state is middle (everything fine here),set which xvb node could be used.
|
||||||
// should wait for it, because algo needs to not be started if at least one node of XvB are not responsive.
|
// should wait for it, because algo needs to not be started if at least one node of XvB are not responsive.
|
||||||
|
@ -199,6 +198,12 @@ impl Helper {
|
||||||
let handle_algo = Arc::new(Mutex::new(None));
|
let handle_algo = Arc::new(Mutex::new(None));
|
||||||
let handle_request = Arc::new(Mutex::new(None));
|
let handle_request = Arc::new(Mutex::new(None));
|
||||||
let mut msg_retry_done = false;
|
let mut msg_retry_done = false;
|
||||||
|
|
||||||
|
// let's create the memory of last hour average sent to p2pool and XvB
|
||||||
|
// tuple (p2pool, xvb)
|
||||||
|
// need to keep it alive even if algo is down, and push values of hashrate sent to p2pool and 0 for XvB.
|
||||||
|
// spawn a task to keep the values updated, looking at hr and pool direction.
|
||||||
|
//
|
||||||
info!("XvB | Entering Process mode... ");
|
info!("XvB | Entering Process mode... ");
|
||||||
loop {
|
loop {
|
||||||
debug!("XvB Watchdog | ----------- Start of loop -----------");
|
debug!("XvB Watchdog | ----------- Start of loop -----------");
|
||||||
|
@ -459,10 +464,6 @@ impl PubXvbApi {
|
||||||
runtime_manual_donation_level,
|
runtime_manual_donation_level,
|
||||||
..pub_api.stats_priv.clone()
|
..pub_api.stats_priv.clone()
|
||||||
},
|
},
|
||||||
p2pool_sent_last_hour_samples: std::mem::take(
|
|
||||||
&mut gui_api.p2pool_sent_last_hour_samples,
|
|
||||||
),
|
|
||||||
xvb_sent_last_hour_samples: std::mem::take(&mut gui_api.xvb_sent_last_hour_samples),
|
|
||||||
..pub_api.clone()
|
..pub_api.clone()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -667,10 +668,6 @@ async fn check_state_outcauses_xvb(
|
||||||
ProcessName::Xvb,
|
ProcessName::Xvb,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ProcessState::Retry => {
|
|
||||||
debug!("XvB | Retry to get stats from https://xmrvsbeast.com in this loop if delay is done.");
|
|
||||||
*first_loop = true;
|
|
||||||
}
|
|
||||||
// nothing to do, we don't want to change other state
|
// nothing to do, we don't want to change other state
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::{
|
||||||
|
|
||||||
use derive_more::Display;
|
use derive_more::Display;
|
||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
use reqwest::Client;
|
use reqwest_middleware::ClientWithMiddleware as Client;
|
||||||
use tokio::spawn;
|
use tokio::spawn;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -128,9 +128,7 @@ impl XvbNode {
|
||||||
// could be used by xmrig who signal that a node is not joignable
|
// could be used by xmrig who signal that a node is not joignable
|
||||||
// or by the start of xvb
|
// or by the start of xvb
|
||||||
// next iteration of the loop of XvB process will verify if all conditions are met to be alive.
|
// next iteration of the loop of XvB process will verify if all conditions are met to be alive.
|
||||||
if process_xvb.lock().unwrap().state != ProcessState::Syncing
|
if process_xvb.lock().unwrap().state != ProcessState::Syncing {
|
||||||
&& process_xvb.lock().unwrap().state != ProcessState::Retry
|
|
||||||
{
|
|
||||||
process_xvb.lock().unwrap().state = ProcessState::Syncing;
|
process_xvb.lock().unwrap().state = ProcessState::Syncing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,10 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
use log::{debug, error, warn};
|
use log::{debug, error, info, warn};
|
||||||
use reqwest::{Client, StatusCode};
|
use reqwest::StatusCode;
|
||||||
|
use reqwest_middleware::ClientWithMiddleware as Client;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use tokio::time::sleep;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
disk::state::ManualDonationLevel,
|
disk::state::ManualDonationLevel,
|
||||||
|
@ -90,7 +90,7 @@ impl XvbPrivStats {
|
||||||
]
|
]
|
||||||
.concat(),
|
.concat(),
|
||||||
)
|
)
|
||||||
.timeout(Duration::from_secs(5))
|
.timeout(Duration::from_secs(10))
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
match resp.status() {
|
match resp.status() {
|
||||||
|
@ -122,6 +122,16 @@ impl XvbPrivStats {
|
||||||
Ok(new_data) => {
|
Ok(new_data) => {
|
||||||
debug!("XvB Watchdog | HTTP API request OK");
|
debug!("XvB Watchdog | HTTP API request OK");
|
||||||
pub_api.lock().unwrap().stats_priv = new_data;
|
pub_api.lock().unwrap().stats_priv = new_data;
|
||||||
|
let previously_failed = process.lock().unwrap().state == ProcessState::Failed;
|
||||||
|
if previously_failed {
|
||||||
|
info!("XvB Watchdog | Public stats are working again");
|
||||||
|
output_console(
|
||||||
|
&mut gui_api.lock().unwrap().output,
|
||||||
|
"requests for public API are now working",
|
||||||
|
ProcessName::Xvb,
|
||||||
|
);
|
||||||
|
process.lock().unwrap().state = ProcessState::Syncing;
|
||||||
|
}
|
||||||
// if last request failed, we are now ready to show stats again and maybe be alive next loop.
|
// if last request failed, we are now ready to show stats again and maybe be alive next loop.
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
@ -129,22 +139,20 @@ impl XvbPrivStats {
|
||||||
"XvB Watchdog | Could not send HTTP private API request to: {}\n:{}",
|
"XvB Watchdog | Could not send HTTP private API request to: {}\n:{}",
|
||||||
XVB_URL, err
|
XVB_URL, err
|
||||||
);
|
);
|
||||||
|
if process.lock().unwrap().state != ProcessState::Failed {
|
||||||
|
output_console(
|
||||||
|
&mut gui_api.lock().unwrap().output,
|
||||||
|
"Failure to retrieve private stats \nWill retry shortly...",
|
||||||
|
ProcessName::Xvb,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// we stop the algo (will be stopped by the check status on next loop) because we can't make the rest work without public stats. (winner in xvb private stats).
|
||||||
output_console(
|
output_console(
|
||||||
&mut gui_api.lock().unwrap().output,
|
&mut gui_api.lock().unwrap().output,
|
||||||
&format!(
|
"request to get private API failed",
|
||||||
"Failure to retrieve private stats from {} because of this error: {}",
|
|
||||||
XVB_URL, err
|
|
||||||
),
|
|
||||||
ProcessName::Xvb,
|
ProcessName::Xvb,
|
||||||
);
|
);
|
||||||
process.lock().unwrap().state = ProcessState::Retry;
|
process.lock().unwrap().state = ProcessState::Failed;
|
||||||
// sleep here because it is in a spawn and will not block the user stopping or restarting the service.
|
|
||||||
output_console(
|
|
||||||
&mut gui_api.lock().unwrap().output,
|
|
||||||
"Waiting 10 seconds before trying to get stats again.",
|
|
||||||
ProcessName::Xvb,
|
|
||||||
);
|
|
||||||
sleep(Duration::from_secs(10)).await;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,10 @@ use std::{
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use log::{debug, warn};
|
use log::{debug, info, warn};
|
||||||
use reqwest::Client;
|
use reqwest_middleware::ClientWithMiddleware as Client;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_this_or_that::as_u64;
|
use serde_this_or_that::as_u64;
|
||||||
use tokio::time::sleep;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
helper::{xvb::output_console, Process, ProcessName, ProcessState},
|
helper::{xvb::output_console, Process, ProcessName, ProcessState},
|
||||||
|
@ -47,7 +46,7 @@ impl XvbPubStats {
|
||||||
) -> std::result::Result<Self, anyhow::Error> {
|
) -> std::result::Result<Self, anyhow::Error> {
|
||||||
Ok(client
|
Ok(client
|
||||||
.get(XVB_URL_PUBLIC_API)
|
.get(XVB_URL_PUBLIC_API)
|
||||||
.timeout(Duration::from_secs(5))
|
.timeout(Duration::from_secs(10))
|
||||||
.send()
|
.send()
|
||||||
.await?
|
.await?
|
||||||
.json::<Self>()
|
.json::<Self>()
|
||||||
|
@ -64,24 +63,25 @@ impl XvbPubStats {
|
||||||
Ok(new_data) => {
|
Ok(new_data) => {
|
||||||
debug!("XvB Watchdog | HTTP API request OK");
|
debug!("XvB Watchdog | HTTP API request OK");
|
||||||
pub_api.lock().unwrap().stats_pub = new_data;
|
pub_api.lock().unwrap().stats_pub = new_data;
|
||||||
// if last request failed, we are now ready to show stats again and maybe be alive next loop.
|
let previously_failed = process.lock().unwrap().state == ProcessState::Failed;
|
||||||
if process.lock().unwrap().state == ProcessState::Retry {
|
if previously_failed {
|
||||||
process.lock().unwrap().state = ProcessState::Syncing;
|
info!("XvB Watchdog | Public stats are working again");
|
||||||
output_console(
|
output_console(
|
||||||
&mut gui_api.lock().unwrap().output,
|
&mut gui_api.lock().unwrap().output,
|
||||||
"Stats are now working again after last successful request.",
|
"requests for public API are now working",
|
||||||
ProcessName::Xvb,
|
ProcessName::Xvb,
|
||||||
);
|
);
|
||||||
|
process.lock().unwrap().state = ProcessState::Syncing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(
|
warn!(
|
||||||
"XvB Watchdog | Could not send HTTP API request to: {}\n:{}",
|
"XvB Watchdog | Could not send HTTP API request to: {} even after multiples tries\n:{}",
|
||||||
XVB_URL_PUBLIC_API, err
|
XVB_URL_PUBLIC_API, err
|
||||||
);
|
);
|
||||||
// output the error to console
|
// output the error to console
|
||||||
// if error already present, no need to print it multiple times.
|
// if error already present, no need to print it multiple times.
|
||||||
if process.lock().unwrap().state != ProcessState::Retry {
|
if process.lock().unwrap().state != ProcessState::Failed {
|
||||||
output_console(
|
output_console(
|
||||||
&mut gui_api.lock().unwrap().output,
|
&mut gui_api.lock().unwrap().output,
|
||||||
&format!(
|
&format!(
|
||||||
|
@ -92,14 +92,12 @@ impl XvbPubStats {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// we stop the algo (will be stopped by the check status on next loop) because we can't make the rest work without public stats. (winner in xvb private stats).
|
// we stop the algo (will be stopped by the check status on next loop) because we can't make the rest work without public stats. (winner in xvb private stats).
|
||||||
process.lock().unwrap().state = ProcessState::Retry;
|
|
||||||
// sleep here because it is in a spawn and will not block the user stopping or restarting the service.
|
|
||||||
output_console(
|
output_console(
|
||||||
&mut gui_api.lock().unwrap().output,
|
&mut gui_api.lock().unwrap().output,
|
||||||
"Waiting 10 seconds before trying to get stats again.",
|
"request to get public API failed",
|
||||||
ProcessName::Xvb,
|
ProcessName::Xvb,
|
||||||
);
|
);
|
||||||
sleep(Duration::from_secs(10)).await;
|
process.lock().unwrap().state = ProcessState::Failed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
12
src/miscs.rs
12
src/miscs.rs
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
// Get absolute [Gupax] binary path
|
// Get absolute [Gupax] binary path
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
use std::time::Duration;
|
||||||
#[cold]
|
#[cold]
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
pub fn get_exe() -> Result<String, std::io::Error> {
|
pub fn get_exe() -> Result<String, std::io::Error> {
|
||||||
|
@ -134,6 +135,7 @@ use chrono::Local;
|
||||||
use log::error;
|
use log::error;
|
||||||
use log::warn;
|
use log::warn;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
use reqwest_middleware::ClientWithMiddleware;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -170,3 +172,13 @@ pub fn output_console_without_time(output: &mut String, msg: &str, p_name: Proce
|
||||||
fn datetimeonsole() -> String {
|
fn datetimeonsole() -> String {
|
||||||
format!("[{}] ", Local::now().format("%Y-%m-%d %H:%M:%S%.3f"))
|
format!("[{}] ", Local::now().format("%Y-%m-%d %H:%M:%S%.3f"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn client() -> ClientWithMiddleware {
|
||||||
|
reqwest_middleware::ClientBuilder::new(reqwest::Client::new())
|
||||||
|
.with(reqwest_retry::RetryTransientMiddleware::new_with_policy(
|
||||||
|
reqwest_retry::policies::ExponentialBackoff::builder()
|
||||||
|
.retry_bounds(Duration::from_secs(1), Duration::from_secs(5))
|
||||||
|
.build_with_total_retry_duration(Duration::from_secs(20)),
|
||||||
|
))
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue