Skip to content

Commit

Permalink
revert influx lib upgrade; Influx smoke test before listening on http…
Browse files Browse the repository at this point in the history
… port. (#307)
  • Loading branch information
alsuren authored Oct 1, 2024
1 parent 525e32b commit 557986f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-stats-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
21 changes: 10 additions & 11 deletions stats-server/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions stats-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ authors = ["David Laban <alsuren@gmail.com>"]
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"
1 change: 1 addition & 0 deletions stats-server/fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
app = "cargo-quickinstall-stats-server"
kill_signal = "SIGINT"
kill_timeout = 5
deploy.strategy = "bluegreen"

[env]
PORT = "8080"
Expand Down
12 changes: 12 additions & 0 deletions stats-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 557986f

Please sign in to comment.