Compare commits

...

8 commits
v0.2 ... main

Author SHA1 Message Date
95480163c9
Update README.md 2025-08-03 17:27:10 +02:00
557edb1abd
Update README.md 2025-08-03 16:44:28 +02:00
316a40442e Add metrics endpoint 2024-03-31 15:44:39 +02:00
13f89b68ef
Update Dockerfile 2023-08-27 14:24:07 +02:00
8bd8676314 update 2023-08-27 13:54:40 +02:00
89f533e357
Update Dockerfile 2023-08-27 13:49:41 +02:00
e4d1c77422
Merge pull request #2 from danielhenrymantilla/patch-1
Try <!-- [skip ci] --> it
2023-01-17 17:47:20 +01:00
Daniel Henry-Mantilla
ae0ea732e9
Try <!-- [skip ci] --> it 2023-01-17 17:46:10 +01:00
8 changed files with 746 additions and 275 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use nix

2
.gitignore vendored
View file

@ -1,2 +1,2 @@
/target /target
bisect.sqlite bisect.sqlite

963
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -9,6 +9,9 @@ edition = "2021"
axum = "0.5.16" axum = "0.5.16"
chrono = { version = "0.4.22", features = ["serde", "clock"] } chrono = { version = "0.4.22", features = ["serde", "clock"] }
color-eyre = "0.6.2" color-eyre = "0.6.2"
metrics = "0.22.3"
metrics-exporter-prometheus = { version = "0.14.0", default-features = false, features = ["http-listener"] }
once_cell = "1.19.0"
rusqlite = { version = "0.28.0", features = ["bundled", "uuid", "chrono"] } rusqlite = { version = "0.28.0", features = ["bundled", "uuid", "chrono"] }
serde = { version = "1.0.145", features = ["derive"] } serde = { version = "1.0.145", features = ["derive"] }
tempdir = "0.3.7" tempdir = "0.3.7"

View file

@ -1,4 +1,4 @@
FROM rust as build FROM rust:1.77 as build
RUN rustup toolchain install nightly RUN rustup toolchain install nightly
RUN rustup default nightly RUN rustup default nightly
@ -12,22 +12,30 @@ COPY Cargo.toml Cargo.lock ./
RUN mkdir src RUN mkdir src
RUN echo "fn main() {}" > src/main.rs RUN echo "fn main() {}" > src/main.rs
RUN cargo build --release -Zsparse-registry RUN cargo build --release
COPY src ./src COPY src ./src
COPY index.html index.html COPY index.html index.html
# now rebuild with the proper main # now rebuild with the proper main
RUN touch src/main.rs RUN touch src/main.rs
RUN cargo build --release -Zsparse-registry RUN cargo build --release
### RUN ### RUN
FROM rust FROM rust:1.77
RUN cargo install cargo-bisect-rustc RUN cargo install cargo-bisect-rustc
WORKDIR /app WORKDIR /app
# random user
RUN useradd --create-home bisector
USER bisector
# this server listens on port 4000 and 4001 (metrics)
EXPOSE 4000
EXPOSE 4001
COPY --from=build /app/target/release/cargo-bisect-rustc-service cargo-bisect-rustc-service COPY --from=build /app/target/release/cargo-bisect-rustc-service cargo-bisect-rustc-service
CMD ["/app/cargo-bisect-rustc-service"] CMD ["/app/cargo-bisect-rustc-service"]

View file

@ -1,4 +1,9 @@
# cargo-bisect-rustc-service # cargo-bisect-rustc-service
**⚠️ this service has been turned off due to lack of usage ⚠️**
if you think it's useful you should tell me so i can turn it on again
a small web service that bisects rustc for you a small web service that bisects rustc for you
https://nilstrieb.dev/bisect-rustc https://bisect-rustc.noratrieb.dev

3
shell.nix Normal file
View file

@ -0,0 +1,3 @@
{ pkgs ? import <nixpkgs> { } }: pkgs.mkShell {
packages = with pkgs; [ rustup ];
}

View file

@ -4,7 +4,10 @@ mod bisect;
mod db; mod db;
mod toolchain; mod toolchain;
use std::sync::{mpsc, Arc, Mutex}; use std::{
future,
sync::{mpsc, Arc, Mutex},
};
use crate::bisect::Job; use crate::bisect::Job;
use axum::{ use axum::{
@ -15,6 +18,7 @@ use axum::{
Extension, Json, Extension, Json,
}; };
use color_eyre::eyre::Context; use color_eyre::eyre::Context;
use metrics_exporter_prometheus::{PrometheusBuilder, PrometheusHandle};
use rusqlite::Connection; use rusqlite::Connection;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::env; use std::env;
@ -38,6 +42,22 @@ async fn main() -> color_eyre::Result<()> {
) )
.init(); .init();
let metrics_app = async {
let prom_handle = setup_metrics();
let router: Router =
Router::new().route("/metrics", get(move || future::ready(prom_handle.render())));
info!("Starting up metrics server on port 4001");
axum::Server::bind(&"0.0.0.0:4001".parse().unwrap())
.serve(router.into_make_service())
.await
.wrap_err("failed to start server")
};
tokio::try_join!(metrics_app, main_server())?;
Ok(())
}
async fn main_server() -> color_eyre::Result<()> {
let (job_queue_send, job_queue_recv) = mpsc::sync_channel(10); let (job_queue_send, job_queue_recv) = mpsc::sync_channel(10);
let sqlite_db = env::var("SQLITE_DB").unwrap_or_else(|_| "bisect.sqlite".to_string()); let sqlite_db = env::var("SQLITE_DB").unwrap_or_else(|_| "bisect.sqlite".to_string());
@ -115,6 +135,7 @@ async fn do_bisection(
body: String, body: String,
send_channel: Extension<SendChannel>, send_channel: Extension<SendChannel>,
) -> impl IntoResponse { ) -> impl IntoResponse {
metrics::counter!("bisections").increment(1);
let job_id = Uuid::new_v4(); let job_id = Uuid::new_v4();
let job = Job::new(job_id, body, options.0); let job = Job::new(job_id, body, options.0);
@ -130,3 +151,6 @@ async fn do_bisection(
)), )),
} }
} }
pub fn setup_metrics() -> PrometheusHandle {
PrometheusBuilder::new().install_recorder().unwrap()
}