From 557986f1df3cf1fa3b6eea03a9a784bd4a7255c3 Mon Sep 17 00:00:00 2001 From: David Laban Date: Tue, 1 Oct 2024 16:53:33 +0100 Subject: [PATCH] revert influx lib upgrade; Influx smoke test before listening on http port. (#307) --- .github/workflows/deploy-stats-server.yml | 2 +- stats-server/Cargo.lock | 21 ++++++++++----------- stats-server/Cargo.toml | 5 +++-- stats-server/fly.toml | 1 + stats-server/src/main.rs | 12 ++++++++++++ 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/.github/workflows/deploy-stats-server.yml b/.github/workflows/deploy-stats-server.yml index cbbcba67a4..2ddcd1fda8 100644 --- a/.github/workflows/deploy-stats-server.yml +++ b/.github/workflows/deploy-stats-server.yml @@ -12,6 +12,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: superfly/flyctl-actions/setup-flyctl@master - - run: flyctl deploy stats-server + - run: flyctl deploy stats-server --wait-timeout 1m env: FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} diff --git a/stats-server/Cargo.lock b/stats-server/Cargo.lock index 0a087d0da7..2dfb12db77 100644 --- a/stats-server/Cargo.lock +++ b/stats-server/Cargo.lock @@ -41,9 +41,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.4.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "axum" @@ -210,9 +210,9 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.4.76+curl-8.10.1" +version = "0.4.74+curl-8.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00462dbe9cbb9344e1b2be34d9094d74e3b8aac59a883495b335eafd02e25120" +checksum = "8af10b986114528fcdc4b63b6f5f021b7057618411046a4de2ba0f0149a097bf" dependencies = [ "cc", "libc", @@ -434,9 +434,8 @@ dependencies = [ [[package]] name = "influxrs" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae2b0b3d0ecac700fd3b3833d8faf40e3606e9759fa232758998a098a69670c5" +version = "2.0.1" +source = "git+https://github.com/alsuren/influxrs?rev=bc037531ef31e0a19014556120ecdd151427561b#bc037531ef31e0a19014556120ecdd151427561b" dependencies = [ "csv", "isahc", @@ -638,9 +637,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "polling" @@ -962,9 +961,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.24" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] diff --git a/stats-server/Cargo.toml b/stats-server/Cargo.toml index 0823363854..f8c9ea1fa2 100644 --- a/stats-server/Cargo.toml +++ b/stats-server/Cargo.toml @@ -6,13 +6,14 @@ authors = ["David Laban "] edition = "2021" publish = false -# Make a new workspace so that we get our own Cargo.lock and target dir for the docker build. +# Make a new workspace so that we get our own Cargo.lock and target dir for the docker build. [workspace] [dependencies] tokio = { version = "1", features = ["rt-multi-thread", "macros"] } axum = "0.7" -influxrs = { version = "3", features = ["client"] } +# FIXME: revert back to using crates.io once https://github.com/ijagberg/influx/pull/5 is released +influxrs = { git = "https://github.com/alsuren/influxrs", rev = "bc037531ef31e0a19014556120ecdd151427561b" } [profile.release] lto = "thin" diff --git a/stats-server/fly.toml b/stats-server/fly.toml index 7525771556..b4b8ed5ae7 100644 --- a/stats-server/fly.toml +++ b/stats-server/fly.toml @@ -3,6 +3,7 @@ app = "cargo-quickinstall-stats-server" kill_signal = "SIGINT" kill_timeout = 5 +deploy.strategy = "bluegreen" [env] PORT = "8080" diff --git a/stats-server/src/main.rs b/stats-server/src/main.rs index 001254836a..2007cd30c8 100644 --- a/stats-server/src/main.rs +++ b/stats-server/src/main.rs @@ -27,6 +27,18 @@ fn main() { .route("/record-install", get(redirect_to_root)) .route("/record-install", post(record_install)); + // Smoke test that we can write to influxdb before listening on the socket. + // This is a poor man's startup probe to avoid serving traffic before we can write to influxdb. + INFLUX_CLIENT + .write( + &INFLUX_BUCKET, + &[Measurement::builder("startups") + .field("count", 1) + .build() + .unwrap()], + ) + .await + .unwrap(); // ipv6 + ipv6 any addr let addr = SocketAddr::from(([0, 0, 0, 0, 0, 0, 0, 0], 8080)); let listener = TcpListener::bind(addr).await.unwrap();